How can I set a form's backcolor to a custom color (such as light pink) using C# code?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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
回答2:
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;