TreeView.HotTracking Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Recebe ou define um valor que indica se a etiqueta de um nó em árvore assume a aparência de um hiperlink à medida que o ponteiro do rato passa por cima dele.
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 Propriedade
true se uma etiqueta de nó em árvore assumir a aparência de um hiperlink à medida que o ponteiro do rato passa por cima dela; caso contrário, false. A predefinição é false.
Exemplos
O seguinte exemplo de código ilustra um .TreeView Ao herdar a TreeView classe, esta versão personalizada tem toda a funcionalidade de um típico TreeView. Alterar vários valores de propriedades no construtor confere uma aparência única. Como a ShowPlusMinus propriedade está definida para false, o controlo personalizado também sobrepõe o OnAfterSelect método para que os nós possam ser expandidos e colapsados quando são clicados.
Um controlo personalizado desta forma pode ser utilizado em toda a organização, facilitando a disponibilização de uma interface consistente sem exigir que as propriedades de controlo 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
Observações
Se a CheckBoxes propriedade for definida para true, a HotTracking propriedade não tem efeito.
Note
Quando a HotTracking propriedade é definida para true, cada rótulo de nó de árvore assume a aparência de um hiperlink à medida que o ponteiro do rato passa por cima dele. O Underline estilo da fonte é aplicado ao Font e o ForeColor é definido para azul para que o rótulo apareça como um link. A aparência não é controlada pelas definições de Internet do sistema operativo do utilizador.