TreeViewAction 枚举

指定引发 TreeViewEventArgs 事件的操作。

**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)

语法

声明
Public Enumeration TreeViewAction
用法
Dim instance As TreeViewAction
public enum TreeViewAction
public enum class TreeViewAction
public enum TreeViewAction
public enum TreeViewAction

成员

  成员名称 说明
由 .NET Compact Framework 支持 ByKeyboard 此事件由按键操作引发。 
由 .NET Compact Framework 支持 ByMouse 此事件由鼠标操作引发。 
由 .NET Compact Framework 支持 Collapse 此事件由 TreeNode 折叠操作引发。 
由 .NET Compact Framework 支持 Expand 此事件由 TreeNode 展开操作引发。 
由 .NET Compact Framework 支持 Unknown 引发此事件的操作未知。 

备注

此枚举由 TreeViewEventArgs 构造函数之类的成员使用。

示例

下面的代码示例阐释了如何使用 TreeView.AfterSelect 事件和 TreeViewAction 枚举。要运行该示例,请将以下代码粘贴到一个窗体中,而该窗体包含名为 TreeView1 的 TreeView 控件。此示例假定 TreeView1 填充有一些项,并且 TreeView.AfterSelect 事件被连接到示例中定义的事件处理方法。

' 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
// 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;
    }
}
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(Object sender,
    System.Windows.Forms.TreeViewEventArgs e)
{
    // Vary the response depending on which TreeViewAction
    // triggered the event. 
    switch (e.get_Action()) {
        case TreeViewAction.ByKeyboard:
            MessageBox.Show("You like the keyboard!");
            break;
        case TreeViewAction.ByMouse:
            MessageBox.Show("You like the mouse!");
            break;
    }
} //treeView1_AfterSelect

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

System.Windows.Forms 命名空间
TreeViewEventArgs