开发者

C# UseVisualStyleBackColor

开发者 https://www.devze.com 2023-01-31 06:50 出处:网络
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)

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)

C# UseVisualStyleBackColor

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号