TreeView.HotTracking Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri vagy beállít egy értéket, amely jelzi, hogy egy facsomópontcímke felveszi-e a hivatkozás megjelenését, miközben az egérmutató áthalad rajta.
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
Tulajdonság értéke
trueha egy facsomópont felirata egy hivatkozás megjelenését veszi át, miközben az egérmutató áthalad rajta; egyéb esetben. false Az alapértelmezett érték a false.
Példák
Az alábbi példakód egy testre szabott TreeViewkódot mutat be. Az osztály öröklésével ez az TreeView egyéni verzió egy tipikus TreeViewfunkcióval rendelkezik. A konstruktor különböző tulajdonságértékeinek módosítása egyedi megjelenést biztosít. Mivel a ShowPlusMinus tulajdonság be van állítva false, a testreszabott vezérlő felülbírálja a metódust is, így a OnAfterSelect csomópontok kibonthatók és összecsukhatók, amikor rákattintanak.
Az ilyen módon testre szabott vezérlők a szervezet egészében használhatók, így egyszerűen konzisztens felületet biztosíthat anélkül, hogy minden egyes projektben meg kellene adni a vezérlőtulajdonságokat.
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
Megjegyzések
Ha a CheckBoxes tulajdonság be van állítva true, a HotTracking tulajdonságnak nincs hatása.
Note
HotTracking A tulajdonság beállításakor trueminden facsomópontcímke egy hivatkozás megjelenését veszi figyelembe, miközben az egérmutató áthalad rajta. A Underline program a betűstílust alkalmazza, Font és kékre ForeColor állítja, így a címke hivatkozásként jelenik meg. A megjelenést nem a felhasználó operációs rendszerének internetes beállításai vezérlik.