TreeViewEventArgs Osztály
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.
Adatokat biztosít a AfterCheckvezérlőelemek , AfterCollapse, AfterExpandvagy AfterSelect események számára TreeView .
public ref class TreeViewEventArgs : EventArgs
public class TreeViewEventArgs : EventArgs
type TreeViewEventArgs = class
inherit EventArgs
Public Class TreeViewEventArgs
Inherits EventArgs
- Öröklődés
Példák
Az alábbi példa egy testre szabott TreeViewképet mutat be. Az osztály öröklésével ez az TreeView egyéni verzió a normál TreeViewverzió összes funkcióját biztosítja. A konstruktor különböző tulajdonságértékeinek módosítása egyedi megjelenést biztosít. Mivel a ShowPlusMinus tulajdonság értéke hamis, 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
Az események kezelésével kapcsolatos további információkért lásd : Események kezelése és emelése.
Konstruktorok
| Name | Description |
|---|---|
| TreeViewEventArgs(TreeNode, TreeViewAction) |
Inicializálja a TreeViewEventArgs megadott facsomópont osztályának új példányát, valamint az eseményt okozó művelettípust. |
| TreeViewEventArgs(TreeNode) |
Inicializálja a TreeViewEventArgs megadott facsomópont osztályának új példányát. |
Tulajdonságok
| Name | Description |
|---|---|
| Action |
Lekéri az eseményt okozó művelet típusát. |
| Node |
Lekéri az ellenőrzött, kibontott, összecsukott vagy kijelölt facsomópontot. |
Metódusok
| Name | Description |
|---|---|
| Equals(Object) |
Meghatározza, hogy a megadott objektum egyenlő-e az aktuális objektummal. (Öröklődés forrása Object) |
| GetHashCode() |
Ez az alapértelmezett kivonatoló függvény. (Öröklődés forrása Object) |
| GetType() |
Lekéri az Type aktuális példányt. (Öröklődés forrása Object) |
| MemberwiseClone() |
Az aktuális Objectpéldány sekély másolatát hozza létre. (Öröklődés forrása Object) |
| ToString() |
Az aktuális objektumot jelképező sztringet ad vissza. (Öröklődés forrása Object) |