Sdílet prostřednictvím


TreeView.AfterSelect Událost

Definice

Nastane po výběru uzlu stromu.

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 použití výčtu TreeViewAction . Chcete-li spustit tento příklad, vložte následující kód do formuláře, který obsahuje TreeView ovládací prvek s názvem TreeView1. Tento příklad vyžaduje, aby TreeView1 byla naplněna položkami a AfterSelect událost je připojena 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

K této události nedojde, pokud 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í naleznete v tématu Zpracování a vyvolávání událostí.

Platí pro

Viz také