When I call ControlPaint.DrawButton, the button that is drawn is in the non-themed background color. How do I draw a control that looks like a button (including themed drawing) in .Net 2.0 (C#)?
The ControlPaint methods do not support visual styles, that's why it looks all messed up (try taking out this line of code in your Program.cs Application.EnableVisualStyles(); and everything will look like that button and you'll see what I mean.)
The correct method you should be using is the ButtonRender.DrawButton(..) method. This does honor visual styles and will thus render correctly. Quick sample:
ButtonRenderer.DrawButton(this.CreateGraphics(),
new Rectangle(20, 20, 100, 40),"Click me!",
new Font(this.Font, FontStyle.Regular),false,
System.Windows.Forms.VisualStyles.PushButtonState.Normal);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With