Share via


How to: Change the Background Color of a Form

This example changes the background color of a Windows Form programmatically.

Example

private void Form1_Click(object sender, EventArgs e)
{
    this.BackColor = System.Drawing.Color.DarkBlue;
}

Compiling the Code

This example requires:

  • A form named Form1. Set its Click event handler to Form1_Click.

See Also

Concepts

Designing a User Interface in Visual C#

Other Resources

Customizing, Displaying, and Printing Windows Forms

Visual C# Guided Tour