ComboBox Item Text Color in .NET Windows Forms

cyberia

Platinum Member
Oct 22, 1999
2,535
0
0
I have a databound ComboBox on a Windows Form. Is it possible to change text color of an arbitrary item in the drop down?

Thanks.
 

UCJefe

Senior member
Jan 27, 2000
302
0
0
Yep. It's possible. Just subclass the ComboBox control, change the DrawMode to OwnerDrawFixed and in the DrawItem event handler, do your drawing. Graphics.DrawString with the right brush will give you a colored item. If you want to have the default drawing for any other items, just call the base method.

Text

If you're doing any sort of WinForms programming that site is your friend.
 

cyberia

Platinum Member
Oct 22, 1999
2,535
0
0
Thanks. I was hoping for a less involved approach like setting a property. Oh well... But I do see a few things I can use on that site.
 

SoftwareEng

Senior member
Apr 24, 2005
553
4
81
Originally posted by: UCJefe
Yep. It's possible. Just subclass the ComboBox control, change the DrawMode to OwnerDrawFixed and in the DrawItem event handler, do your drawing. Graphics.DrawString with the right brush will give you a colored item. If you want to have the default drawing for any other items, just call the base method.

Text

If you're doing any sort of WinForms programming that site is your friend.

Thank you sir, I'll check it out!