Reputation: 7827
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#)?
Upvotes: 3
Views: 1437
Reputation: 103760
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);
Upvotes: 6
Reputation: 40789
The first and second overload have ButtonState
as the last param.
I imagine you want: ButtonState.Normal
, and what you're getting is ButtonState.Flat
?
Upvotes: 0