TreeView.HotTracking Propiedad

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.

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. De manera predeterminada, es false.

Ejemplos

En el ejemplo de código siguiente se muestra un objeto personalizado TreeView. Al heredar la TreeView clase , esta versión personalizada tiene toda la funcionalidad de un típico TreeView. El cambio de varios valores de propiedad en el constructor proporciona una apariencia única. Dado que la ShowPlusMinus propiedad se establece falseen , el control personalizado también invalida el OnAfterSelect método para que los nodos se puedan expandir y contraer cuando se hace clic en ellos.

Un control personalizado de esta manera se puede usar en toda una organización, lo que facilita la prestación de una interfaz coherente sin necesidad de especificar las propiedades de control en cada proyecto individual.

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

Comentarios

Si la CheckBoxes propiedad se establece trueen , la HotTracking propiedad no tiene ningún efecto.

Nota

Cuando la HotTracking propiedad se establece trueen , cada etiqueta de nodo de árbol toma la apariencia de un hipervínculo a medida que el puntero del mouse pasa sobre él. El Underline estilo de fuente se aplica a Font y ForeColor se establece en azul para que la etiqueta aparezca como un vínculo. La apariencia no se controla mediante la configuración de Internet del sistema operativo del usuario.

Se aplica a