TreeView.HotTracking Propriedade

Definição

Obtém ou define um valor que indica que se um rótulo do nó de árvore assume a aparência de um hiperlink quando o ponteiro do mouse passa sobre ele.

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 da propriedade

Boolean

true se um rótulo do nó de árvore assume a aparência de um hiperlink quando o ponteiro do mouse passa sobre ele; caso contrário, false. O padrão é false.

Exemplos

O exemplo de código a seguir ilustra um .TreeView Ao herdar a TreeView classe, essa versão personalizada tem toda a funcionalidade de um típico TreeView. Alterar vários valores de propriedade no construtor fornece uma aparência exclusiva. Como a ShowPlusMinus propriedade está definida como, o controle personalizado também substitui o método para falseque os OnAfterSelect nós possam ser expandidos e recolhidos quando são clicados.

Um controle personalizado dessa forma pode ser usado em toda uma organização, facilitando o uso de uma interface consistente sem exigir que as propriedades de controle sejam especificadas em cada projeto 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

Comentários

Se a CheckBoxes propriedade estiver definida como true, a HotTracking propriedade não terá efeito.

Observação

Quando a HotTracking propriedade é definida como true, cada rótulo de nó de árvore assume a aparência de um hiperlink à medida que o ponteiro do mouse passa sobre ele. O Underline estilo da fonte é aplicado ao Font e é ForeColor definido como azul para fazer com que o rótulo apareça como um link. A aparência não é controlada pelas configurações da Internet do sistema operacional do usuário.

Aplica-se a