TreeView.AfterSelect 事件
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在选定树节点后发生。
public:
event System::Windows::Forms::TreeViewEventHandler ^ AfterSelect;
public event System.Windows.Forms.TreeViewEventHandler AfterSelect;
public event System.Windows.Forms.TreeViewEventHandler? AfterSelect;
member this.AfterSelect : System.Windows.Forms.TreeViewEventHandler
Public Custom Event AfterSelect As TreeViewEventHandler
事件类型
示例
下面的代码示例演示如何使用 TreeViewAction 枚举。 若要运行此示例,请将以下代码粘贴到包含 TreeView 名为 的控件的 TreeView1
窗体中。 此示例要求 TreeView1
使用 项填充 ,并且 事件 AfterSelect 连接到示例中定义的事件处理程序。
private:
// Handle the After_Select event.
void TreeView1_AfterSelect( System::Object^ /*sender*/, System::Windows::Forms::TreeViewEventArgs^ e )
{
// Vary the response depending on which TreeViewAction
// triggered the event.
switch ( (e->Action) )
{
case TreeViewAction::ByKeyboard:
MessageBox::Show( "You like the keyboard!" );
break;
case TreeViewAction::ByMouse:
MessageBox::Show( "You like the mouse!" );
break;
}
}
// Handle the After_Select event.
private void TreeView1_AfterSelect(System.Object sender,
System.Windows.Forms.TreeViewEventArgs e)
{
// Vary the response depending on which TreeViewAction
// triggered the event.
switch((e.Action))
{
case TreeViewAction.ByKeyboard:
MessageBox.Show("You like the keyboard!");
break;
case TreeViewAction.ByMouse:
MessageBox.Show("You like the mouse!");
break;
}
}
' Handle the After_Select event.
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.TreeViewEventArgs) _
Handles TreeView1.AfterSelect
' Vary the response depending on which TreeViewAction
' triggered the event.
Select Case (e.Action)
Case TreeViewAction.ByKeyboard
MessageBox.Show("You like the keyboard!")
Case TreeViewAction.ByMouse
MessageBox.Show("You like the mouse!")
End Select
End Sub
注解
未选择节点时不会发生此事件。 若要检测是否清除了所选内容,可以测试 TreeNode.IsSelected 属性。
有关处理事件的详细信息,请参阅 处理和引发事件。