I'll post only relevent code...

My intent here is a logging system that uses an owner drawn listbox (fixed item height) for custom item background colors (to denote the 'alert level' of the specific item). I'm using a custom class called 'ColorListItem' to store the Text and the Background color of the item:

VB Code:
  1. Public Class ColorListItem
  2.     Public Text As String
  3.     Public Color As System.Drawing.Color
  4.  
  5.     Public Sub New(ByVal NewText As String, ByVal NewColor As System.Drawing.Color)
  6.         Text = NewText
  7.         Color = NewColor
  8.     End Sub
  9. End Class

Each item in the listbox is added in the format of:
VB Code:
  1. lbConsole.Items.Add(New ColorListItem("Text", Drawing.Color.Red)

(Simply an example)

The listbox, lbConsole, has DrawMode set to OwnerDrawFixed so that the MeasureItem event isn't fired. I put the DrawItem event in the sub Log_DrawItem
VB Code:
  1. Sub Log_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs)
  2.         Dim bg As SolidBrush
  3.         Dim cli As Object 'ColorListItem
  4.         'We use Object just incase the item was improperly added
  5.  
  6.         If e.Index = -1 Then Exit Sub 'it looks good when there are no items, no drawing needed
  7.  
  8.         cli = sender.Items(e.Index)
  9.  
  10.         Try 'if cli isn't a valid ColorListItem
  11.             bg = New SolidBrush(cli.color)
  12.         Catch
  13.             bg = New SolidBrush(Drawing.Color.Yellow) 'highlight any problems
  14.         End Try
  15.  
  16.         e.Graphics.FillRectangle(bg, e.Bounds)
  17.         e.Graphics.DrawString(cli.text, e.Font, New SolidBrush(Drawing.Color.Black), e.Bounds.X, e.Bounds.Y)
  18.     End Sub

If, for some reason, it's unable to use the Color property of 'cli', it defaults to yellow. (The scheme I'm using is red-based so it will stand out.)

I intend that the listbox forces it's color scheme over the standard windows colors cheme (i.e. color.black vs systemcolors.controltext)

I also intend that no selection is visible. Alas, I can not set the selection mode to none, becuase I have to be able to scroll to the most recently added item at the bottom (this is done elsewhere in the code).

The issue I'm noticing is that when the listbox adds an item forcing the listbox to scroll, it flickers horribly. I'd like to have it draw as if the drawmode was Normal.

I'm thinking the drawing each item from it's own thread might speed it up, but I can't figure out how to impliment that.

Any ideas to reduce the flicker?