jimmy
jimmy

Reputation: 383

Set form backcolor to custom color

How can I set a form's backcolor to a custom color (such as light pink) using C# code?

Upvotes: 36

Views: 235215

Answers (3)

Kadir GUR
Kadir GUR

Reputation: 1

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;

Upvotes: 0

MusiGenesis
MusiGenesis

Reputation: 75296

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

Upvotes: 104

Brian R. Bondy
Brian R. Bondy

Reputation: 347226

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;

Upvotes: 15

Related Questions