共用方式為


VisualStyleElement.ToolBar.Button 類別

定義

提供 VisualStyleElement 工具列按鈕每個狀態的物件。 無法繼承這個類別。

public: ref class VisualStyleElement::ToolBar::Button abstract sealed
public static class VisualStyleElement.ToolBar.Button
type VisualStyleElement.ToolBar.Button = class
Public Class VisualStyleElement.ToolBar.Button
繼承
VisualStyleElement.ToolBar.Button

範例

以下程式碼範例示範如何用屬性VisualStyleElement回傳Normal的 來建立 aVisualStyleRenderer。 要執行這個範例,請將它貼到 Windows 表單中。 處理表單的Paint事件,並從DrawVisualStyleElementToolBarButton1事件處理方法呼叫該Paint方法,傳遞ePaintEventArgs

public void DrawVisualStyleElementToolBarButton1(PaintEventArgs e)
{
    if (VisualStyleRenderer.IsElementDefined(
        VisualStyleElement.ToolBar.Button.Normal))
    {
        VisualStyleRenderer renderer =
             new VisualStyleRenderer(VisualStyleElement.ToolBar.Button.Normal);
        Rectangle rectangle1 = new Rectangle(10, 50, 50, 50);
        renderer.DrawBackground(e.Graphics, rectangle1);
        e.Graphics.DrawString("VisualStyleElement.ToolBar.Button.Normal",
             this.Font, Brushes.Black, new Point(10, 10));
    }
    else
        e.Graphics.DrawString("This element is not defined in the current visual style.",
             this.Font, Brushes.Black, new Point(10, 10));
}
Public Sub DrawVisualStyleElementToolBarButton1(ByVal e As PaintEventArgs)
    If (VisualStyleRenderer.IsElementDefined( _
     VisualStyleElement.ToolBar.Button.Normal)) Then
        Dim renderer As New VisualStyleRenderer _
          (VisualStyleElement.ToolBar.Button.Normal)
        Dim rectangle1 As New Rectangle(10, 50, 50, 50)
        renderer.DrawBackground(e.Graphics, rectangle1)
        e.Graphics.DrawString("VisualStyleElement.ToolBar.Button.Normal", _
          Me.Font, Brushes.Black, New Point(10, 10))
    Else
        e.Graphics.DrawString("This element is not defined in the current visual style.", _
          Me.Font, Brushes.Black, New Point(10, 10))
    End If
End Sub

備註

類別中的 VisualStyleElement.ToolBar.Button 每個屬性會回傳工具列按鈕不同狀態的 a VisualStyleElement

屬性

名稱 Description
Checked

會取得一個視覺風格元素,代表在勾選狀態下的工具列按鈕。

Disabled

會獲得一個視覺風格元素,代表在停用狀態下的工具列按鈕。

Hot

會有一個視覺風格元素,代表處於熱狀態的工具列按鈕。

HotChecked

會有一個視覺風格元素,代表在熱狀態和勾選狀態下的工具列按鈕。

Normal

會獲得一個視覺風格元素,代表工具列按鈕的正常狀態。

Pressed

會獲得一個視覺風格元素,代表按下狀態下的工具列按鈕。

適用於

另請參閱