简体   繁体   English

C#自定义SimpleButton更改颜色

[英]C# Custom SimpleButton change color

I have done a custom button using a Devexpress SimpleButton and I want to change the color of the button like this, but it doesn't work. 我已经使用Devexpress SimpleButton完成了一个自定义按钮,并且我想像这样更改按钮的颜色,但是它不起作用。

        this.Button.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.Simple;
        this.Button.BackColor = Color.Pink;

I have done the same with the designer and it works fine, but now i want to do it programmatically and it's not working. 我已经与设计师进行了同样的操作,并且效果很好,但是现在我想以编程方式进行操作,并且无法正常工作。 Thanks in advance. 提前致谢。

Make sure to set LookAndFeel.Style to Flat, Ultra Flat or Style3D: 确保将LookAndFeel.Style设置为Flat,Ultra Flat或Style3D:

this.Button.LookAndFeel.Style = LookAndFeelStyle.Flat;
this.Button.LookAndFeel.UseDefaultLookAndFeel = false;
this.Button.Appearance.BackColor = Color.MediumSeaGreen;
this.Button.Appearance.Options.UseBackColor = true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM