C# UseVisualStyleBackColor
Is there a way in which I can change the button color and preserve the Windows VisualStyle? I want to create a button that looks like checkBox2 (color and style)
this.button2.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
this.button2.UseVisualStyleBackColor = fa开发者_如何学Golse; //if true, BackColor gets ignored
No, not really. This kind of button background is drawn by VisualStyleRenderer.DrawBackground(). Which in turns pinvokes DrawThemeBackground(). These methods don't take a color. None is needed because the color is already specified in the theme.
Simulating the appearance with a LinearGradientBrush is your only real hope. Note that custom drawing a button is quite difficult, all the code is internal and no owner-draw is provided.
Consider using an image.
精彩评论