When I set the ForeColor of my ComboBox, ALL of the text turns to that color. Is there a way to set it so that only the text in the TextBox portion of the ComboBox turns to that color, and the rest stays in black text?
Printable View
When I set the ForeColor of my ComboBox, ALL of the text turns to that color. Is there a way to set it so that only the text in the TextBox portion of the ComboBox turns to that color, and the rest stays in black text?
You would have to draw the items yourself if you want to use different text colours. Check out the documentation for the DrawMode property for an explanation and code example.
Its called OwnerDrawn where you handle all the drawing/painting of the items in the list. You can draw in different colors, fonts, and size for each individule item if you want.
If confusing you wish to be the speak in cryptic code you must.
What are you trying to say/ask?
What's confusing or cryptic about this?Quote:
Check out the documentation for the DrawMode property for an explanation and code example.
After a quick search, here is an example from msdn online help pages...
http://msdn2.microsoft.com/en-us/lib....drawmode.aspx
Um, I was practicing my If/Then structure? Or maybe not.
All this stuff seems to come pretty easily for you guys. I assume that it's easy to forget how overwhelming it all can be.
But I know what to look at now for this. Maybe it can be done.
I'll give it a try tomorrow.
How's Australia this time of year? I know a few pedal steel players over there.
I've been through the code at http://msdn2.microsoft.com/en-us/lib....drawmode.aspx
Played around with it. Made it do different stuff. But I couldn't make it do what I want. I don't understand it.
All I want is a ComboBox with these items in these colors.
"Homework" (black"
"Test" (red)
"9 Weeks Test" (blue)
"Semester Test" (green)
I see that I can make the choices in the listbox section have their own colors, though I don't understand exactly how it works. And I know that I can set the ForeColor to my color of choice for the TextBox part of the ComboBox. Of course, setting that changes ALL of the text (including the choices) to that color.
In the example from the link I posted, your link is broken, if you look at the ComboBox1_DrawItem event you can see how it colors the three items in the combo.
I changed a few things and experimented. Finally got the result I was wanting. Actually, something a little better. Thanks.