• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

ComboBox Item Text Color in .NET Windows Forms

cyberia

Platinum Member
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.
 
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.
 
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.
 
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!
 
Back
Top