Hi,

Am hoping someone can help. I want to change the colour of the autocomplete section of a combo box depending on the value of the item. I found the following code to do this for the main drop down section like so.
; Code:
  1. Private Sub cbdept_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles cbdept.DrawItem
  2.         Dim c As System.Drawing.Color
  3.         Dim dcomb As ComboBox
  4.         Try
  5.             dcomb = CType(sender, ComboBox)
  6.  
  7.             'Sometimes calls this procedure with an index of -1
  8.             If e.Index < 0 Then
  9.                 e.DrawBackground()
  10.                 e.DrawFocusRectangle()
  11.             Else
  12.  
  13.                 'Determine colour to use
  14.  
  15.                 Select Case CType(dcomb.Items.Item(e.Index), DataRowView).Item(0).ToString
  16.                     Case "sales"
  17.                         c = Color.FromName("Blue")
  18.                     Case "IT"
  19.                         c = Color.FromName("Green")
  20.                     Case "Accounts"
  21.                         c = Color.FromName("Orange")
  22.                     Case "Red"
  23.                         c = Color.FromName("Red")
  24.                     Case Else
  25.                         c = Color.FromName("Red")
  26.                 End Select
  27.  
  28.                 'Carry out necessary procedures
  29.                 e.DrawBackground()
  30.                 e.DrawFocusRectangle()
  31.  
  32.                 'Create rectangle, fill it with desired colour, and add text
  33.                 e.Graphics.DrawRectangle(New Pen(c), New Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
  34.                 e.Graphics.FillRectangle(New SolidBrush(c), New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
  35.                 e.Graphics.DrawString(CType(dcomb.Items.Item(e.Index), DataRowView).Item(0).ToString, dcomb.Font, New SolidBrush(Color.Black), New RectangleF(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height))
  36.  
  37.  
  38.             End If
  39.      
  40.    
  41.         Catch ex As Exception
  42.             MsgBox(ex.ToString)
  43.         End Try
  44.     End Sub

Not sure how to do the same thing with the autocomplete section though.
Any help would be apreciated.

Cheers