TreeView.HotTracking TreeView.HotTracking TreeView.HotTracking TreeView.HotTracking Property

Definición

Obtiene o establece un valor que indica si la etiqueta de un nodo de árbol toma la apariencia de un hipervínculo cuando el puntero del mouse pasa por encima.Gets or sets a value indicating whether a tree node label takes on the appearance of a hyperlink as the mouse pointer passes over it.

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

Valor de propiedad

Es true si la etiqueta de un nodo de árbol toma la apariencia de un hipervínculo cuando el puntero del mouse pasa por encima; en caso contrario, es false.true if a tree node label takes on the appearance of a hyperlink as the mouse pointer passes over it; otherwise, false. De manera predeterminada, es false.The default is false.

Ejemplos

En el ejemplo de código siguiente se muestra TreeViewun personalizado.The following code example illustrates a customized TreeView. Al heredar la TreeView clase, esta versión personalizada tiene toda la funcionalidad de un típico TreeView.By inheriting the TreeView class, this custom version has all the functionality of a typical TreeView. Cambiar varios valores de propiedad en el constructor proporciona una apariencia única.Changing various property values in the constructor provides a unique appearance. Dado que ShowPlusMinus la propiedad está establecida falseen, el control personalizado también invalida el OnAfterSelect método para que los nodos puedan expandirse y contraerse cuando se haga clic en ellos.Because the ShowPlusMinus property is set to false, the customized control also overrides the OnAfterSelect method so that nodes can be expanded and collapsed when they are clicked.

Un control personalizado de esta manera se puede usar en toda la organización, lo que facilita proporcionar una interfaz coherente sin requerir que se especifiquen las propiedades del control en cada proyecto individual.A control that is customized in this way can be used throughout an organization, making it easy to provide a consistent interface without requiring the control properties to be specified in each individual project.

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 'New


    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 'OnAfterSelect

End Class 'CustomizedTreeView 

Comentarios

Si la CheckBoxes propiedad está establecida en true, la HotTracking propiedad no tiene ningún efecto.If the CheckBoxes property is set to true, the HotTracking property has no effect.

Nota

Cuando la HotTracking propiedad está establecida en true, cada etiqueta de nodo de árbol toma la apariencia de un hipervínculo cuando el puntero del mouse pasa sobre él.When the HotTracking property is set to true, each tree node label takes on the appearance of a hyperlink as the mouse pointer passes over it. El Underline estilo de fuente se aplica Font a y ForeColor se establece en Blue para que la etiqueta aparezca como un vínculo.The Underline font style is applied to the Font and the ForeColor is set to blue to make the label appear as a link. La configuración de Internet del sistema operativo del usuario no controla la apariencia.The appearance is not controlled by the Internet settings of the user's operating system.

Se aplica a