Combobox Selection Color RRS feed

  • Question

  • Hi,

    I want to change the combobox selection color to white.

    if the combobox property dropdownstyle=dropdown and the selectedindex=-1 then combobox background selection color wont change


    but if i change property dropdownstyle=dropdownlist and the selectedindex=-1 then the combobox selection color 

    but i want to show and i dont want the selection color blue i want it as white i only if the item selects also the selection background should be in white like first image and when mouse focus on the dropdown items its should be in blue but in the combobox textbox is should be white

    please help

    thanks in advance

    Friday, June 21, 2013 9:39 AM


  • Hi, 

    i got solution 

    ComboBox1.DrawMode = DrawMode.OwnerDrawVariable

      Private Sub ComboBox1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ComboBox1.DrawItem
        If e.Index < 0 Then Exit Sub
        Dim rect As Rectangle = e.Bounds
        If e.State And DrawItemState.Selected Then
          e.Graphics.FillRectangle(SystemBrushes.Highlight, rect)
          e.Graphics.FillRectangle(SystemBrushes.Window, rect)
        End If

        Dim b2 As SolidBrush
        Dim fillcolor As Color = Color.FromName("Black")
        b2 = New SolidBrush(fillcolor)
        e.Graphics.DrawString(sender.items(e.Index), e.Font, b2, e.Bounds.X, e.Bounds.Y)
      End Sub

    • Marked as answer by Kumar Jalli Friday, June 21, 2013 2:27 PM
    Friday, June 21, 2013 2:27 PM