Assembly: System.Windows.Forms (in system.windows.forms.dll)
Public Property HotTracking As Boolean
Dim instance As TreeView Dim value As Boolean value = instance.HotTracking instance.HotTracking = value
public bool HotTracking { get; set; }
public: property bool HotTracking { bool get (); void set (bool value); }
/** @property */ public boolean get_HotTracking () /** @property */ public void set_HotTracking (boolean value)
public function get HotTracking () : boolean public function set HotTracking (value : boolean)
Valore proprietà
true se l'etichetta di un nodo della struttura assume l'aspetto di un collegamento ipertestuale al passaggio del mouse su di essa; in caso contrario, false. Il valore predefinito è false.| Tipo di eccezione | Condizione |
|---|---|
| Il valore impostato è minore di -1. |
Se la proprietà CheckBoxes è impostata su true, la proprietà HotTracking non avrà alcun effetto.
Nota |
|---|
| Quando la proprietà HotTracking è impostata su true, ciascuna etichetta del nodo della struttura assume l'aspetto di un collegamento ipertestuale al passaggio del mouse su di essa. Lo stile Underline del carattere viene applicato all'oggetto Font mentre la proprietà ForeColor viene impostata su blu affinché l'etichetta assuma l'aspetto di un collegamento ipertestuale. L'aspetto non è determinato dalle impostazioni Internet del sistema operativo dell'utente. |
Nell'esempio di codice riportato di seguito viene illustrato un oggetto TreeView personalizzato. Ereditando la classe TreeView, questa versione personalizzata dispone di tutta la funzionalità di un oggetto TreeView tipico. La modifica di alcuni valori di proprietà nel costruttore fornisce un aspetto univoco. Poiché la proprietà ShowPlusMinus è impostata su false, il controllo personalizzato esegue anche l'override del metodo OnAfterSelect in modo da consentire l'espansione e la compressione dei nodi quando si fa clic su di essi.
Un controllo personalizzato in questo modo può essere utilizzato in tutta un'organizzazione per fornire agevolmente un'interfaccia coerente senza dover specificare le proprietà del controllo in ogni singolo progetto.
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
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 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 extends TreeView
{
public CustomizedTreeView()
{
// Customize the TreeView control by setting various properties.
set_BackColor(System.Drawing.Color.get_CadetBlue());
set_FullRowSelect(true);
set_HotTracking(true);
set_Indent(34);
set_ShowPlusMinus(false);
// The ShowLines property must be false for the FullRowSelect
// property to work.
set_ShowLines(false);
} //CustomizedTreeView
protected 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.get_Action().Equals(TreeViewAction.Unknown))) {
if (e.get_Node().get_IsExpanded()) {
e.get_Node().Collapse();
}
else {
e.get_Node().Expand();
}
}
// Remove the selection. This allows the same node to be
// clicked twice in succession to toggle the expansion state.
set_SelectedNode(null);
} //OnAfterSelect
}//CustomizedTreeView
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile per Pocket PC, Windows Mobile per Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema.
Nota