开发者

Set form backcolor to custom color

开发者 https://www.devze.com 2022-12-31 22:56 出处:网络
How can I set a form\'s backcolor 开发者_运维技巧to a custom color (such as light pink) using C# code?If you want to set the form\'s back color to some arbitrary RGB value, you can do this:

How can I set a form's backcolor 开发者_运维技巧to a custom color (such as light pink) using C# code?


If you want to set the form's back color to some arbitrary RGB value, you can do this:

this.BackColor = Color.FromArgb(255, 232, 232); // this should be pink-ish


With Winforms you can use Form.BackColor to do this.
From within the Form's code:

BackColor = Color.LightPink;

If you mean a WPF Window you can use the Background property.
From within the Window's code:

Background = Brushes.LightPink;


Define BackGround Color ShowDialog

ColorDialog bgColor = new ColorDialog();

After if you want change the color according to selected color

bgColor.ShowDialog();
this.BackColor = bgColor.Color;
0

精彩评论

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