Set form backcolor to custom color

被刻印的时光 ゝ 提交于 2019-12-18 11:45:05

问题


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;


来源:https://stackoverflow.com/questions/2891686/set-form-backcolor-to-custom-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!