title: listbox item forecolor change
body: <p>Does anyone know why the Listbox1.Refresh() command may not trigger the ListBox1_DrawItem sub every time?</p>
  <p>In Microsoft Visual Basic 2010, a listbox has a forcolor and backcolor property. These properties change the forcolour and backcolor for all the items in the listbox. By default there is no property for the forecolor and backcolor of an individual item on a listbox, I am aware there is on a list view but I would still wish to use a listbox.
  I am trying to have the ability to change the forecolor and backcolor properties of individual items in the listbox.
  To do this the listbox's draw item sub must be used with the listbox's drawmode property set to OwnerDrawFixed. Then using a brush colour along with the e.graphics the forecolor or backcolor can be changed.
  I have seen and followed examples of how to do this for the currently selected item. Such as the one from <a href="http://www.ehow.co.uk/how_8494128_change-listbox-items-visual-basic.html" rel="nofollow noreferrer">ehow's website</a>.
  What I am tiring to do however is change the colour of the litsbox item as it is added depending on a variable.</p>
  <p>Here is my code:</p>
  <pre><code>    Private Sub listbox_add()
  
          Me.ListBox1.Items.Add(listbox_text(list_num)) ' adds the line to the list box
          add_item_colour = True
          ListBox1.Refresh()
  
  End Sub
  
  
  
      Private Sub ListBox1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem
      Dim myBrush As Brush = Brushes.Black
  
      e.DrawBackground()
      If add_item_colour = True Then
          If blue_message = True Then
              myBrush = Brushes.Blue
          Else
              myBrush = Brushes.Black
          End If
          e.Graphics.DrawString(ListBox1.Items.Item(list_num), ListBox1.Font, myBrush, _
          New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
          add_item_colour = False
      End If
      e.DrawFocusRectangle()
  End Sub
  </code></pre>
  <p>The listbox_text is a string array that stores the string being added, the list_num is a integer that increments when new items are added to the listbox and the blue_message is a Boolean that it true when I want a blue message and false when I don't.</p>
  <p>The problem I seem to be having is that Listbox1.Refresh() command does not seem to be triggering the ListBox1_DrawItem sub every time it is called. I found this by using brake points. Does anyone know why this might be the case and how I could fix it?</p>
  <p>Thanks, any help on this would be much appreciated.</p>