我正在查看TreeView events而没有看到它。
例如,BeforeSelect显示新节点:
private void myTreeView_BeforeSelect(Object sender, TreeViewCancelEventArgs eventArgs)
{
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
string node = "\tNode: " + eventArgs.Node; // This is the new node
string action = "\tAction: " + eventArgs.Action; // ByMouse
string cancel = "\tCancel: " + eventArgs.Cancel; // False
}
答案 0 :(得分:3)
您可以使用((TreeView) sender).SelectedNode
private void myTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs eventArgs)
{
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
string node = "\tNode: " + eventArgs.Node; // This is the new node
string action = "\tAction: " + eventArgs.Action; // ByMouse
string cancel = "\tCancel: " + eventArgs.Cancel; // False
//Get the current selected node/old node after the select processed
var oldNode = ((TreeView) sender).SelectedNode;
}