Export (0) Print
Expand All
Expand Minimize

Code: Changing the Background Color of a Form (Visual C#)

Visual Studio .NET 2003

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

Example

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

Compiling the Code

This example requires:

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

See Also

Windows Forms Example Topics | Color Structure

Show:
© 2014 Microsoft