TreeView.AfterSelect Událost

Definice

Nastane po výběru uzlu stromové struktury.

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 

Event Type

Příklady

Následující příklad kódu ukazuje, jak použít TreeViewAction výčet. Chcete-li spustit tento příklad, vložte následující kód do formuláře, který obsahuje ovládací prvek TreeView s názvem TreeView1. Tento příklad vyžaduje, aby TreeView1 byla naplněna položkami a AfterSelect událost je připojená k obslužné rutině události definované v ukázce.

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

Poznámky

Tato událost nenastane, když uzel není vybrán. Pokud chcete zjistit, jestli byl výběr vymazán, můžete vlastnost otestovat TreeNode.IsSelected .

Další informace o zpracování událostí najdete v tématu Zpracování a vyvolávání událostí.

Platí pro

Viz také