Application.VisualStyleState 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得值,指定視覺化樣式套用至應用程式視窗的方式。
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 會決定是否在用戶端應用程式區域或應用程式視窗的非用戶端區域中啟用視覺樣式。 一般而言,此屬性應該設定在主表單的建構函式或 Load 事件處理常式內。