Articles in this section
Category / Section

How to customize the WinForms ComboBox (ComboBoxAdv) dropdown items?

1 min read

Customization of ComboBoxAdv items

ComboBoxAdv items can be customized by setting DrawMode as OwnerDrawFixed and by handling DrawItem event. You can set the different fore color or back color for ComboBoxAdv items

 C#

//Set the draw mode
this.comboBoxAdv1.ListBox.DrawMode = DrawMode.OwnerDrawFixed;
void ListBox_DrawItem(object sender, DrawItemEventArgs e)
{     //Set particular item backcolor     e.Graphics.FillRectangle(new SolidBrush(Color.LightBlue), e.Bounds);     //Set particular item Text color     e.Graphics.DrawString(text, e.Font, new SolidBrush(Color.Purple), e.Bounds);
}

 

 VB

'Set the draw mode
Me.comboBoxAdv1.ListBox.DrawMode = DrawMode.OwnerDrawFixed
Private Sub ListBox_DrawItem(ByVal sender As Object, ByVal e As DrawItemEventArgs)
    'Set particular item backcolor
    e.Graphics.FillRectangle(New SolidBrush(Color.LightBlue), e.Bounds)
    'Set particular item Text color
    e.Graphics.DrawString(text, e.Font, New SolidBrush(Color.Purple), e.Bounds)
End Sub

 

ComboBoxAdv items with different colors

Figure 1: ComboBoxAdv items with different forecolor and different backcolor

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ComboBoxAdv_Itemcolor-82816323.zip

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied