TreeView.AfterSelect Zdarzenie

Definicja

Występuje po wybraniu węzła drzewa.

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 

Typ zdarzenia

Przykłady

W poniższym przykładzie kodu pokazano, jak używać TreeViewAction wyliczenia. Aby uruchomić ten przykład, wklej następujący kod w formularzu zawierającym kontrolkę TreeView o nazwie TreeView1. Ten przykład wymaga TreeView1 wypełnienia elementami, a AfterSelect zdarzenie jest połączone z procedurą obsługi zdarzeń zdefiniowaną w przykładzie.

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

Uwagi

To zdarzenie nie występuje, gdy węzeł jest niezaznaczony. Aby wykryć, czy zaznaczenie zostało wyczyszczone, możesz przetestować TreeNode.IsSelected właściwość .

Aby uzyskać więcej informacji na temat obsługi zdarzeń, zobacz Obsługa i podnoszenie zdarzeń.

Dotyczy

Zobacz też