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
NoneEnabledVisual styles are not applied to the application.
ClientAreaEnabledVisual styles are applied only to the client area.
NonClientAreaEnabledVisual styles are applied only to the nonclient area.
ClientAndNonClientAreasEnabledVisual styles are applied to client and nonclient areas.

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

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

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

© 2016 Microsoft