problems with creategraphics and combo_click event.

  • Thread starter Thread starter S Domadia
  • Start date Start date
S

S Domadia

hi,
now actually i want to design custom combo in which combo's button (in
which down arrow is there to perform clicking for dropdown type of
combo) should be also black in color. so as it's not possible directly
to change that i drawn image over that click button of combo using
this.comboBox1.CreateGraphics().FillRectangle(System.Drawing.Brushes.Black,90,0,20,30);
but it is drawing this only once on form load and when i click on
combo this image disappears so my problem is this even after clicking
a combo that image should remain there.how can i do it?

It would be great help to me if you can provide any suggestion.

Regards,
S. Domadia.
 
Hi S Domadia,

This behaviour is as expected. The comboBox is repainted at various times, for instance when you click the button. However (I assume you put your painting code in the form's paint event), the combobox's text box and button handles it's own drawing, and doesn't let you take part of it. So when clicking, the form won't get noticed, so the form won't paint the black rectangle.

There may be some way to tap into windows to capture the button drawing event, but I'm not sure how to do it. You may have to make your own custom control. Maybe using a text box, a button, and a list box.

Happy coding!
Morten Wennevik [C# MVP]
 
Back
Top