TreeViewAction Enum

Definisi

Menentukan tindakan yang memunculkan TreeViewEventArgs peristiwa.

public enum class TreeViewAction
public enum TreeViewAction
type TreeViewAction = 
Public Enum TreeViewAction
Warisan
TreeViewAction

Bidang

ByKeyboard 1

Peristiwa ini disebabkan oleh penekanan tombol.

ByMouse 2

Peristiwa ini disebabkan oleh operasi mouse.

Collapse 3

Peristiwa ini disebabkan oleh runtuhnya TreeNode peristiwa tersebut.

Expand 4

Peristiwa ini disebabkan oleh perluasan TreeNode .

Unknown 0

Tindakan yang menyebabkan peristiwa tidak diketahui.

Contoh

Contoh kode berikut menunjukkan cara menggunakan TreeView.AfterSelect peristiwa dan TreeViewAction enumerasi. Untuk menjalankan contoh tempelkan kode berikut dalam formulir yang berisi kontrol TreeView bernama TreeView1. Contoh ini mengasumsikan TreeView1 diisi dengan item dan TreeView.AfterSelect peristiwa terhubung ke metode penanganan peristiwa yang ditentukan dalam sampel.

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

Keterangan

Enumerasi ini digunakan oleh anggota seperti TreeViewEventArgs konstruktor.

Berlaku untuk

Lihat juga