TreeViewEventArgs TreeViewEventArgs TreeViewEventArgs TreeViewEventArgs Class

定義

AfterCheck コントロールの AfterCollapseAfterExpandAfterSelectTreeView の各イベントのデータを提供します。Provides data for the AfterCheck, AfterCollapse, AfterExpand, or AfterSelect events of a TreeView control.

public ref class TreeViewEventArgs : EventArgs
public class TreeViewEventArgs : EventArgs
type TreeViewEventArgs = class
    inherit EventArgs
Public Class TreeViewEventArgs
Inherits EventArgs
継承
TreeViewEventArgsTreeViewEventArgsTreeViewEventArgsTreeViewEventArgs

次の例は、カスタマイズTreeViewされたを示しています。The following example illustrates a customized TreeView. TreeViewクラスを継承することにより、このカスタムバージョンには通常TreeViewのすべての機能が含まれます。By inheriting the TreeView class, this custom version has all the functionality of a normal TreeView. コンストラクター内のさまざまなプロパティ値を変更すると、独自の外観が提供されます。Changing various property values in the constructor provides a unique appearance. プロパティがShowPlusMinus false に設定されているため、カスタマイズされOnAfterSelectたコントロールは、ノードがクリックされたときに展開および折りたたむことができるように、メソッドもオーバーライドします。Because the ShowPlusMinus property is set to false, the customized control also overrides the OnAfterSelect method so nodes can be expanded and collapsed when they are clicked.

この方法でカスタマイズされたコントロールを組織全体で使用できます。これにより、各プロジェクトでコントロールプロパティを指定しなくても、一貫したインターフェイスを簡単に提供できるようになります。A control that is customized in this way can be used throughout an organization, making it easy to provide a consistent interface without requiring the control properties to be specified in each individual project.

public ref class CustomizedTreeView: public TreeView
{
public:
   CustomizedTreeView()
   {

      // Customize the TreeView control by setting various properties.
      BackColor = System::Drawing::Color::CadetBlue;
      FullRowSelect = true;
      HotTracking = true;
      Indent = 34;
      ShowPlusMinus = false;

      // The ShowLines property must be false for the FullRowSelect
      // property to work.
      ShowLines = false;
   }

protected:
   virtual void OnAfterSelect( TreeViewEventArgs^ e ) override
   {
      // Confirm that the user initiated the selection.
      // This prevents the first node from expanding when it is
      // automatically selected during the initialization of
      // the TreeView control.
      if ( e->Action != TreeViewAction::Unknown )
      {
         if ( e->Node->IsExpanded )
         {
            e->Node->Collapse();
         }
         else
         {
            e->Node->Expand();
         }
      }

      
      // Remove the selection. This allows the same node to be
      // clicked twice in succession to toggle the expansion state.
      SelectedNode = nullptr;
   }
};
public class CustomizedTreeView : TreeView
{
    public CustomizedTreeView()
    {
        // Customize the TreeView control by setting various properties.
        BackColor = System.Drawing.Color.CadetBlue;
        FullRowSelect = true;
        HotTracking = true;
        Indent = 34;
        ShowPlusMinus = false;

        // The ShowLines property must be false for the FullRowSelect 
        // property to work.
        ShowLines = false;
    }

    protected override void OnAfterSelect(TreeViewEventArgs e)
    {
        // Confirm that the user initiated the selection.
        // This prevents the first node from expanding when it is
        // automatically selected during the initialization of 
        // the TreeView control.
        if (e.Action != TreeViewAction.Unknown)
        {
            if (e.Node.IsExpanded) 
            {
                e.Node.Collapse();
            }
            else 
            {
                e.Node.Expand();
            }
        }

        // Remove the selection. This allows the same node to be
        // clicked twice in succession to toggle the expansion state.
        SelectedNode = null;
    }

}
Public Class CustomizedTreeView
    Inherits TreeView

    Public Sub New()
        ' Customize the TreeView control by setting various properties.
        BackColor = System.Drawing.Color.CadetBlue
        FullRowSelect = True
        HotTracking = True
        Indent = 34
        ShowPlusMinus = False

        ' The ShowLines property must be false for the FullRowSelect 
        ' property to work.
        ShowLines = False
    End Sub


    Protected Overrides Sub OnAfterSelect(ByVal e As TreeViewEventArgs)
        ' Confirm that the user initiated the selection.
        ' This prevents the first node from expanding when it is
        ' automatically selected during the initialization of 
        ' the TreeView control.
        If e.Action <> TreeViewAction.Unknown Then
            If e.Node.IsExpanded Then
                e.Node.Collapse()
            Else
                e.Node.Expand()
            End If
        End If

        ' Remove the selection. This allows the same node to be
        ' clicked twice in succession to toggle the expansion state.
        SelectedNode = Nothing
    End Sub

End Class 'CustomizedTreeView 

注釈

イベントの処理の詳細については、「処理とイベントの発生」を参照してください。For more information about handling events, see Handling and Raising Events.

コンストラクター

TreeViewEventArgs(TreeNode) TreeViewEventArgs(TreeNode) TreeViewEventArgs(TreeNode) TreeViewEventArgs(TreeNode)

対象となるツリー ノードを指定して、TreeViewEventArgs クラスの新しいインスタンスを初期化します。Initializes a new instance of the TreeViewEventArgs class for the specified tree node.

TreeViewEventArgs(TreeNode, TreeViewAction) TreeViewEventArgs(TreeNode, TreeViewAction) TreeViewEventArgs(TreeNode, TreeViewAction) TreeViewEventArgs(TreeNode, TreeViewAction)

対象となるツリー ノードおよびイベントを発生させたアクションの種類を指定して、TreeViewEventArgs クラスの新しいインスタンスを初期化します。Initializes a new instance of the TreeViewEventArgs class for the specified tree node and with the specified type of action that raised the event.

プロパティ

Action Action Action Action

イベントを発生させたアクションの種類を取得します。Gets the type of action that raised the event.

Node Node Node Node

チェックされた、展開された、折りたたまれた、または選択されたツリー ノードを取得します。Gets the tree node that has been checked, expanded, collapsed, or selected.

メソッド

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

指定したオブジェクトが、現在のオブジェクトと等しいかどうかを判断します。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

既定のハッシュ関数として機能します。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

現在のインスタンスの Type を取得します。Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

現在の Object の簡易コピーを作成します。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

現在のオブジェクトを表す文字列を返します。Returns a string that represents the current object.

(Inherited from Object)

適用対象

こちらもご覧ください