共用方式為


TreeViewAction 列舉

定義

指定引發 TreeViewEventArgs 事件的動作。

public enum class TreeViewAction
public enum TreeViewAction
type TreeViewAction = 
Public Enum TreeViewAction
繼承
TreeViewAction

欄位

ByKeyboard 1

這個事件是由按鍵所造成。

ByMouse 2

這個事件是由滑鼠作業所造成。

Collapse 3

這個事件是由於收合 TreeNode 所造成。

Expand 4

這個事件是由於展開 TreeNode 所造成。

Unknown 0

造成事件的動作未知。

範例

下列程式碼範例示範如何使用 TreeView.AfterSelect 事件和 TreeViewAction 列舉。 若要執行範例,請將下列程式碼貼到包含名為 TreeView1 之 TreeView 控制項的表單中。 此範例假設 TreeView1 會填入專案,而且 TreeView.AfterSelect 事件會連接到範例中定義的事件處理方法。

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

備註

這個列舉是由建構函式之類的 TreeViewEventArgs 成員使用。

適用於

另請參閱