VisualStyleState Enumeration
Collapse the table of content
Expand the table of content

VisualStyleState Enumeration


Specifies how visual styles are applied to the current application.

Namespace:   System.Windows.Forms.VisualStyles
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public enum VisualStyleState

Member nameDescription

Visual styles are applied to client and nonclient areas.


Visual styles are applied only to the client area.


Visual styles are applied only to the nonclient area.


Visual styles are not applied to the application.

This enumeration is used by the Application.VisualStyleState property to specify whether visual styles are applied to client or nonclient areas of application windows.

Legacy Code Example

The following code example is a simple program that applies visual styles in each of the four areas specified by the VisualStyleState values. To enable visual styles in a certain area, click the option button (also known as a radio button) that represents the area you want to enable, and click the Update VisualStyleState button to observe the changes in the window.

using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;

namespace VisualStyleStateSample
	class Form1 : Form
		Button button1 = new Button();
		RadioButton radioButton1 = new RadioButton();
		RadioButton radioButton2 = new RadioButton();
		RadioButton radioButton3 = new RadioButton();
		RadioButton radioButton4 = new RadioButton();

		public Form1()
			button1.AutoSize = true;
			button1.Location = new Point(10, 10);
			button1.Text = "Update VisualStyleState";
			button1.Click += new EventHandler(button1_Click);

			radioButton1.Location = new Point(10, 50);
			radioButton1.AutoSize = true;
			radioButton1.Text = "Apply styles to client area only";

			radioButton2.Location = new Point(10, 70);
			radioButton2.AutoSize = true;
			radioButton2.Text = "Apply styles to nonclient area only";

			radioButton3.Location = new Point(10, 90);
			radioButton3.AutoSize = true;
			radioButton3.Text = "Apply styles to client and nonclient areas";

			radioButton4.Location = new Point(10, 110);
			radioButton4.AutoSize = true;
			radioButton4.Text = "Disable styles in all areas";

			this.Text = "VisualStyleState Test";
			this.Controls.AddRange(new Control[] { button1,  
                radioButton1, radioButton2, radioButton3, radioButton4});

		static void Main()
			Application.Run(new Form1());

		void button1_Click(object sender, EventArgs e)
			if (radioButton1.Checked)
				Application.VisualStyleState =
			else if (radioButton2.Checked)
				Application.VisualStyleState =
			else if (radioButton3.Checked)
				Application.VisualStyleState =
			else if (radioButton4.Checked)
				Application.VisualStyleState =

			// Repaint the form and all child controls.

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft