TreeView.HotTracking-Eigenschaft
Ruft einen Wert ab, der angibt, ob eine Strukturknotenbezeichnung als Hyperlink dargestellt wird, wenn der Mauszeiger darüber bewegt wird, oder legt diesen fest.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Property HotTracking As Boolean
'Usage
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)
Eigenschaftenwert
true, wenn eine Strukturknotenbezeichnung als Hyperlink dargestellt wird, wenn der Mauszeiger darüber bewegt wird, andernfalls false. Der Standardwert ist false.
Ausnahmen
Ausnahmetyp | Bedingung |
---|---|
Der festgelegte Wert ist kleiner als -1. |
Hinweise
Wenn die CheckBoxes-Eigenschaft auf true festgelegt ist, hat die HotTracking-Eigenschaft keine Auswirkungen.
Hinweis
Wenn die HotTracking-Eigenschaft auf true festgelegt ist, wird jede Strukturknotenbezeichnung als Hyperlink dargestellt, während der Mauszeiger darüber bewegt wird. Der Underline-Schriftschnitt wird auf Font angewendet und ForeColor auf Blau festgelegt, um die Bezeichnung als Hyperlink darzustellen. Die Darstellung wird nicht durch die Interneteinstellungen im Betriebssystem des Benutzers gesteuert.
Beispiel
Im folgenden Codebeispiel wird eine angepasste TreeView veranschaulicht. Durch Vererben der TreeView-Klasse besitzt diese benutzerdefinierte Version den gesamten Funktionsumfang einer normalen TreeView. Durch Ändern verschiedener Eigenschaftenwerte im Konstruktor erreichen Sie eine individuelle Darstellung. Da die ShowPlusMinus-Eigenschaft auf false festgelegt ist, überschreibt das angepasste Steuerelement auch die OnAfterSelect-Methode, sodass Knoten durch Klicken erweitert und reduziert werden können.
Auf diese Weise angepasste Steuerelemente können in der gesamten Organisation verwendet werden. Sie können somit eine konsistente Oberfläche bereitstellen, ohne dass die Eigenschaften des Steuerelements in jedem einzelnen Projekt angegeben werden müssen.
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
Plattformen
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
TreeView-Klasse
TreeView-Member
System.Windows.Forms-Namespace