TreeView.AfterSelect 事件
在选定树节点后发生。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Event AfterSelect As TreeViewEventHandler
用法
Dim instance As TreeView
Dim handler As TreeViewEventHandler
AddHandler instance.AfterSelect, handler
public event TreeViewEventHandler AfterSelect
public:
event TreeViewEventHandler^ AfterSelect {
void add (TreeViewEventHandler^ value);
void remove (TreeViewEventHandler^ value);
}
/** @event */
public void add_AfterSelect (TreeViewEventHandler value)
/** @event */
public void remove_AfterSelect (TreeViewEventHandler value)
JScript 支持使用事件,但不支持进行新的声明。
备注
取消选定节点时不会发生此事件。若要检测发生的这种情况,请处理 Control.MouseUp 事件并测试 TreeNode.IsSelected 属性。
有关处理事件的更多信息,请参见 使用事件。
示例
下面的代码示例阐释了如何使用 TreeViewAction 枚举。若要运行此示例,请将以下代码粘贴到一个包含名为 TreeView1
的 TreeView 控件的窗体中。此示例要求 TreeView1
填充有一些项,并且 AfterSelect 事件被连接到示例中定义的事件处理程序。
' 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
// 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;
}
}
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(Object sender,
System.Windows.Forms.TreeViewEventArgs e)
{
// Vary the response depending on which TreeViewAction
// triggered the event.
switch (e.get_Action()) {
case TreeViewAction.ByKeyboard:
MessageBox.Show("You like the keyboard!");
break;
case TreeViewAction.ByMouse:
MessageBox.Show("You like the mouse!");
break;
}
} //treeView1_AfterSelect
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0
请参见
参考
TreeView 类
TreeView 成员
System.Windows.Forms 命名空间
OnAfterSelect
BeforeSelect
OnBeforeSelect
Control.MouseUp 事件
TreeNode.IsSelected 属性