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.

適用対象

こちらもご覧ください