)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: ComboBoxAdv |
Published Date: November 20, 2014 |
Last Revised Date: November 14, 2019

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

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon