Application.VisualStyleState 属性

定义

获取指定可视样式如何应用于应用程序窗口的值。

public:
 static property System::Windows::Forms::VisualStyles::VisualStyleState VisualStyleState { System::Windows::Forms::VisualStyles::VisualStyleState get(); void set(System::Windows::Forms::VisualStyles::VisualStyleState value); };
public static System.Windows.Forms.VisualStyles.VisualStyleState VisualStyleState { get; set; }
static member VisualStyleState : System.Windows.Forms.VisualStyles.VisualStyleState with get, set
Public Shared Property VisualStyleState As VisualStyleState

属性值

VisualStyleState 值的按位组合。

示例

下面的代码示例将 VisualStyleState 属性设置为 控件的事件处理程序中的Click值之System.Windows.Forms.VisualStyles.VisualStyleStateButton。 此代码示例是为枚举提供的更大示例的 System.Windows.Forms.VisualStyles.VisualStyleState 一部分。

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);
    }
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);
}
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

注解

此属性 VisualStyleState 确定是在应用程序窗口的工作区还是非工作区中启用视觉样式。 通常,应在main窗体的构造函数或Load事件处理程序中设置此属性。

适用于