Ownerdrawn combobox (hopefully not to be plundered this time)

G

Guest

I have an ownerdrawn combo box which I am drawing with an image and some text, this is all working beautifully apart from the difference in the Brush I have to draw the background and the text with if the item is the currently selected one.

I have selected a blue (SystemColors.Highlight) background brush and white (SystemColors.HighlightText) text brush if the item is the highlighted one, but when I do that instead of functioning like a normal combobox (when dropped down) where the items get selected as you mouse over them, as you mouse over each one, the previously selected (i.e. drawn blue) one *stays selected* until you scroll.

Obviously I don't want this behaviour. I've checked I haven't got some multiselect property on or anything. I've written a function which I call to draw the item unselected which in the OnDrawItem I always call to unselect the previous item which is a bit of a kludge, but is there a more normal way? I tried faffing around with the Invalidate method but to no avail.

Oh and another thing is there anyway to get the combo box in its default mode (i.e. with the text box enabled) to show the picture in the text box, as it does on drop down list mode (but I want the text box to stay enabled)... probably not, but just in case! I've got the combo box set to drop down (the standard, i.e. not 'drop down list' or 'simple')
 
S

Shakir Hussain

Beeves,

Can you paste your ComboBox class code with paint events? It will help me to
investigate further.

--
Shak
(Houston)


Beeeeeeeeeeeeves said:
I have an ownerdrawn combo box which I am drawing with an image and some
text, this is all working beautifully apart from the difference in the Brush
I have to draw the background and the text with if the item is the currently
selected one.
I have selected a blue (SystemColors.Highlight) background brush and white
(SystemColors.HighlightText) text brush if the item is the highlighted one,
but when I do that instead of functioning like a normal combobox (when
dropped down) where the items get selected as you mouse over them, as you
mouse over each one, the previously selected (i.e. drawn blue) one *stays
selected* until you scroll.
Obviously I don't want this behaviour. I've checked I haven't got some
multiselect property on or anything. I've written a function which I call to
draw the item unselected which in the OnDrawItem I always call to unselect
the previous item which is a bit of a kludge, but is there a more normal
way? I tried faffing around with the Invalidate method but to no avail.
Oh and another thing is there anyway to get the combo box in its default
mode (i.e. with the text box enabled) to show the picture in the text box,
as it does on drop down list mode (but I want the text box to stay
enabled)... probably not, but just in case! I've got the combo box set to
drop down (the standard, i.e. not 'drop down list' or 'simple')
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top