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

範例

下列程式碼範例示範如何使用 屬性傳回的 Normal 建立 VisualStyleRendererVisualStyleElement 。 若要執行此範例,請將它貼到 Windows Form 中。 處理表單的事件 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 的每個屬性都會 VisualStyleElement 針對工具列按鈕的不同狀態傳回 。

屬性

Checked

取得視覺化樣式項目,表示處於選取狀態的工具列按鈕。

Disabled

取得視覺化樣式項目,表示處於停用狀態的工具列按鈕。

Hot

取得視覺化樣式項目,表示處於作用中狀態的工具列按鈕。

HotChecked

取得視覺化樣式項目,表示處於作用中且選取狀態的工具列按鈕。

Normal

取得視覺化樣式項目,表示處於正常狀態的工具列按鈕。

Pressed

取得視覺化樣式項目,表示處於已按下狀態的工具列按鈕。

適用於

另請參閱