Reputation: 301
I'm just messing about with the Visual Styles offered by .NET using Winforms and I have a problem. I am simply executing this code, called from the OnPaint method of a custom Panel, nothing special.
private void DrawBox(PaintEventArgs e)
{
ComboBoxRenderer.DrawDropDownButton(e.Graphics, e.ClipRectangle, ComboBoxState.Normal);}
My problem is that the Background Color of the Button is grey while the Background Color of a true ComboBox is white (on my Computer anyway).
Two questions here, why the Color change and how do I make my Button render using the same Background Color as a true ComboBox?
Thanks Danny
Upvotes: 2
Views: 266
Reputation: 81675
ClipRectangle is not what you want. Set the actual rectangle you want to draw. That being said, yeah, using VisualStyles is going to make you mad. This will get you close:
VisualStyleRenderer vsr = new VisualStyleRenderer("EDIT", 1, 1);
vsr.DrawBackground(e.Graphics, controlRectangle);
vsr.SetParameters("COMBOBOX", 7, 1);
vsr.DrawBackground(e.Graphics, arrowRectangle);
Upvotes: 3