Export (0) Print
Expand All
Expand Minimize

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 class VisualStyleState

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

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.Drawing.dll>
#using <System.Windows.Forms.dll>
#using <System.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::VisualStyles;

namespace VisualStyleStateSample
    public ref class VisualStyleStateForm : public Form
        Button^ updateButton;
        RadioButton^ applyToClient;
        RadioButton^ applyToNonClient;
        RadioButton^ applyToAll;
        RadioButton^ disableStyles;

            updateButton = gcnew Button();
            applyToClient = gcnew RadioButton();
            applyToNonClient = gcnew RadioButton();
            applyToAll = gcnew RadioButton();
            disableStyles = gcnew RadioButton();

            updateButton->AutoSize = true;
            updateButton->Location = Point(10, 10);
            updateButton->Text = "Update VisualStyleState";
            updateButton->Click += gcnew EventHandler(this, 

            applyToClient->Location = Point(10, 50);
            applyToClient->AutoSize = true;
            applyToClient->Text = "Apply styles to client area only";

            applyToNonClient->Location = Point(10, 70);
            applyToNonClient->AutoSize = true;
            applyToNonClient->Text = "Apply styles to nonclient area only";

            applyToAll->Location = Point(10, 90);
            applyToAll->AutoSize = true;
            applyToAll->Text = "Apply styles to client and nonclient areas";

            disableStyles->Location = Point(10, 110);
            disableStyles->AutoSize = true;
            disableStyles->Text = "Disable styles in all areas";

            this->Text = "VisualStyleState Test";
            this->Controls->AddRange(gcnew array<Control^>{updateButton,
                applyToClient, applyToNonClient, applyToAll, disableStyles});

        void UpdateButton_Click(Object^ sender, EventArgs^ e)
            if (applyToClient->Checked)
                Application::VisualStyleState =
            else if (applyToNonClient->Checked)
                Application::VisualStyleState =
            else if (applyToAll->Checked)
                Application::VisualStyleState =
            else if (disableStyles->Checked)
                Application::VisualStyleState =

            // Repaint the form and all child controls. 

int main()
    Application::Run(gcnew VisualStyleStateSample::VisualStyleStateForm());

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

© 2014 Microsoft