Share via


VisualStyleElement.TreeView.Item.Selected Vlastnost

Definice

Získá prvek vizuálního stylu, který představuje položku stromového zobrazení, která je ve vybraném stavu a má fokus.

public:
 static property System::Windows::Forms::VisualStyles::VisualStyleElement ^ Selected { System::Windows::Forms::VisualStyles::VisualStyleElement ^ get(); };
public static System.Windows.Forms.VisualStyles.VisualStyleElement Selected { get; }
static member Selected : System.Windows.Forms.VisualStyles.VisualStyleElement
Public Shared ReadOnly Property Selected As VisualStyleElement

Hodnota vlastnosti

Představuje VisualStyleElement položku stromového zobrazení, která je ve vybraném stavu a má fokus.

Příklady

Následující příklad kódu ukazuje, jak vytvořit VisualStyleRenderer s VisualStyleElement vrácenou Selected vlastností . Pokud chcete spustit tento příklad, vložte ho do formuláře Windows Form. Zpracujte Paint událost formuláře a zavolejte metodu DrawVisualStyleElementTreeViewItem3Paint z metody zpracování událostí a předejte e ji jako PaintEventArgs.

public void DrawVisualStyleElementTreeViewItem3(PaintEventArgs e)
{
    if (VisualStyleRenderer.IsElementDefined(
        VisualStyleElement.TreeView.Item.Selected))
    {
        VisualStyleRenderer renderer =
             new VisualStyleRenderer(VisualStyleElement.TreeView.Item.Selected);
        Rectangle rectangle1 = new Rectangle(10, 50, 50, 50);
        renderer.DrawBackground(e.Graphics, rectangle1);
        e.Graphics.DrawString("VisualStyleElement.TreeView.Item.Selected",
             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 DrawVisualStyleElementTreeViewItem3(ByVal e As PaintEventArgs)
    If (VisualStyleRenderer.IsElementDefined( _
     VisualStyleElement.TreeView.Item.Selected)) Then
        Dim renderer As New VisualStyleRenderer _
          (VisualStyleElement.TreeView.Item.Selected)
        Dim rectangle1 As New Rectangle(10, 50, 50, 50)
        renderer.DrawBackground(e.Graphics, rectangle1)
        e.Graphics.DrawString("VisualStyleElement.TreeView.Item.Selected", _
          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

Poznámky

K vytvoření můžete použít VisualStyleElement objekt vrácený SelectedVisualStyleRenderervlastností .

Platí pro