TreeView.AfterSelect TreeView.AfterSelect TreeView.AfterSelect TreeView.AfterSelect Event

定义

在选定树节点后发生。Occurs after the tree node is selected.

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枚举。The following code example demonstrates how to use the TreeViewAction enumeration. 若要运行此示例,请将以下代码粘贴到包含TreeView名为TreeView1的控件的窗体中。To run this example, paste the following code in a form that contains a TreeView control named TreeView1. 此示例要求TreeView1填充有项,并将AfterSelect事件连接到在示例中定义的事件处理程序。This example requires that TreeView1 is populated with items and the AfterSelect event is connected to the event handler defined in the sample.

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

注解

如果未选择节点,则不会发生此事件。This event does not occur when the node is unselected. 若要检测所选内容是否已清除,可以测试TreeNode.IsSelected属性。To detect whether the selection was cleared, you can test the TreeNode.IsSelected property.

有关处理事件的详细信息, 请参阅处理和引发事件For more information about handling events, see Handling and Raising Events.

适用于

另请参阅