Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 4
Application Class
 VisualStyleState Property
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2010/.NET Framework 4

Other versions are also available for the following:
.NET Framework Class Library
Application..::.VisualStyleState Property

Gets a value that specifies how visual styles are applied to application windows.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
Visual Basic
Public Shared Property VisualStyleState As VisualStyleState
C#
public static VisualStyleState VisualStyleState { get; set; }
Visual C++
public:
static property VisualStyleState VisualStyleState {
    VisualStyleState get ();
    void set (VisualStyleState value);
}
F#
static member VisualStyleState : VisualStyleState with get, set

This VisualStyleState property determines whether visual styles are enabled in client areas or nonclient areas of application windows. Generally, this property should be set within the main form's constructor or Load event handler.

The following code example sets the VisualStyleState property to one of the System.Windows.Forms.VisualStyles..::.VisualStyleState values within the Click event handler for a Button control. This code example is part of a larger example provided for the System.Windows.Forms.VisualStyles..::.VisualStyleState enumeration.

Visual Basic
Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) _
    Handles button1.Click

    If radioButton1.Checked Then
        Application.VisualStyleState = _
            VisualStyleState.ClientAreaEnabled
    ElseIf radioButton2.Checked Then
        Application.VisualStyleState = _
            VisualStyleState.NonClientAreaEnabled
    ElseIf radioButton3.Checked Then
        Application.VisualStyleState = _
            VisualStyleState.ClientAndNonClientAreasEnabled
    ElseIf radioButton4.Checked Then
        Application.VisualStyleState = _
            VisualStyleState.NoneEnabled
    End If

    ' Repaint the form and all child controls.
    Me.Invalidate(True)
End Sub
C#
        void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                Application.VisualStyleState =
                    VisualStyleState.ClientAreaEnabled;
            }
            else if (radioButton2.Checked)
            {
                Application.VisualStyleState =
                    VisualStyleState.NonClientAreaEnabled;
            }
            else if (radioButton3.Checked)
            {
                Application.VisualStyleState =
                    VisualStyleState.ClientAndNonClientAreasEnabled;
            }
            else if (radioButton4.Checked)
            {
                Application.VisualStyleState =
                    VisualStyleState.NoneEnabled;
            }

            // Repaint the form and all child controls.
            this.Invalidate(true);
        }
Visual C++
private:
    void UpdateButton_Click(Object^ sender, EventArgs^ e)
    {
        if (applyToClient->Checked)
        {
            Application::VisualStyleState =
                VisualStyleState::ClientAreaEnabled;
        }
        else if (applyToNonClient->Checked)
        {
            Application::VisualStyleState =
                VisualStyleState::NonClientAreaEnabled;
        }
        else if (applyToAll->Checked)
        {
            Application::VisualStyleState =
                VisualStyleState::ClientAndNonClientAreasEnabled;
        }
        else if (disableStyles->Checked)
        {
            Application::VisualStyleState =
                VisualStyleState::NoneEnabled;
        }

        // Repaint the form and all child controls.
        this->Invalidate(true);
    }

.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.
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker