TreeView.HotTracking Vlastnost

Definice

Získá nebo nastaví hodnotu označující, zda popisek stromového uzlu přebírá vzhled hypertextového odkazu při průchodu ukazatelem myši.

public:
 property bool HotTracking { bool get(); void set(bool value); };
public bool HotTracking { get; set; }
member this.HotTracking : bool with get, set
Public Property HotTracking As Boolean

Hodnota vlastnosti

Boolean

true pokud popisek uzlu stromu převezme vzhled hypertextového odkazu při průchodu ukazatelem myši; falsev opačném případě . Výchozí formát je false.

Příklady

Následující příklad kódu znázorňuje přizpůsobenou TreeView. Dědění TreeView třídy, tato vlastní verze má všechny funkce typické TreeView. Změna různých hodnot vlastností v konstruktoru poskytuje jedinečný vzhled. Vzhledem k tomu, že ShowPlusMinus vlastnost je nastavena na false, vlastní ovládací prvek také přepíše metodu OnAfterSelect , aby uzly bylo možné rozbalit a sbalit po kliknutí.

Ovládací prvek, který je tímto způsobem přizpůsobený, lze použít v celé organizaci, což usnadňuje poskytování konzistentního rozhraní, aniž by bylo nutné zadat vlastnosti ovládacího prvku v každém jednotlivém projektu.

public ref class CustomizedTreeView: public TreeView
{
public:
   CustomizedTreeView()
   {

      // Customize the TreeView control by setting various properties.
      BackColor = System::Drawing::Color::CadetBlue;
      FullRowSelect = true;
      HotTracking = true;
      Indent = 34;
      ShowPlusMinus = false;

      // The ShowLines property must be false for the FullRowSelect
      // property to work.
      ShowLines = false;
   }

protected:
   virtual void OnAfterSelect( TreeViewEventArgs^ e ) override
   {
      // Confirm that the user initiated the selection.
      // This prevents the first node from expanding when it is
      // automatically selected during the initialization of
      // the TreeView control.
      if ( e->Action != TreeViewAction::Unknown )
      {
         if ( e->Node->IsExpanded )
         {
            e->Node->Collapse();
         }
         else
         {
            e->Node->Expand();
         }
      }

      
      // Remove the selection. This allows the same node to be
      // clicked twice in succession to toggle the expansion state.
      SelectedNode = nullptr;
   }
};
public class CustomizedTreeView : TreeView
{
    public CustomizedTreeView()
    {
        // Customize the TreeView control by setting various properties.
        BackColor = System.Drawing.Color.CadetBlue;
        FullRowSelect = true;
        HotTracking = true;
        Indent = 34;
        ShowPlusMinus = false;

        // The ShowLines property must be false for the FullRowSelect 
        // property to work.
        ShowLines = false;
    }

    protected override void OnAfterSelect(TreeViewEventArgs e)
    {
        // Confirm that the user initiated the selection.
        // This prevents the first node from expanding when it is
        // automatically selected during the initialization of 
        // the TreeView control.
        if (e.Action != TreeViewAction.Unknown)
        {
            if (e.Node.IsExpanded) 
            {
                e.Node.Collapse();
            }
            else 
            {
                e.Node.Expand();
            }
        }

        // Remove the selection. This allows the same node to be
        // clicked twice in succession to toggle the expansion state.
        SelectedNode = null;
    }
}
Public Class CustomizedTreeView
    Inherits TreeView

    Public Sub New()
        ' Customize the TreeView control by setting various properties.
        BackColor = System.Drawing.Color.CadetBlue
        FullRowSelect = True
        HotTracking = True
        Indent = 34
        ShowPlusMinus = False

        ' The ShowLines property must be false for the FullRowSelect 
        ' property to work.
        ShowLines = False
    End Sub


    Protected Overrides Sub OnAfterSelect(ByVal e As TreeViewEventArgs)
        ' Confirm that the user initiated the selection.
        ' This prevents the first node from expanding when it is
        ' automatically selected during the initialization of 
        ' the TreeView control.
        If e.Action <> TreeViewAction.Unknown Then
            If e.Node.IsExpanded Then
                e.Node.Collapse()
            Else
                e.Node.Expand()
            End If
        End If

        ' Remove the selection. This allows the same node to be
        ' clicked twice in succession to toggle the expansion state.
        SelectedNode = Nothing
    End Sub

End Class

Poznámky

Pokud je vlastnost nastavena CheckBoxes na true, HotTracking vlastnost nemá žádný vliv.

Poznámka

Když je vlastnost nastavena HotTracking na true, každý popisek uzlu stromu převezme vzhled hypertextového odkazu, když ukazatel myši předá nad ním. Styl Underline písma se použije na znaméně Font a je ForeColor nastavený na modrou, aby se popisek zobrazoval jako odkaz. Vzhled není řízen nastavením internetu operačního systému uživatele.

Platí pro