TreeViewEventArgsとは? わかりやすく解説

TreeViewEventArgs クラス

TreeView コントロールの AfterCheck、AfterCollapse、AfterExpand、AfterSelect の各イベントデータ提供します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Class TreeViewEventArgs
    Inherits EventArgs
Dim instance As TreeViewEventArgs
public class TreeViewEventArgs : EventArgs
public ref class TreeViewEventArgs : public
 EventArgs
public class TreeViewEventArgs extends EventArgs
public class TreeViewEventArgs extends
 EventArgs
解説解説
使用例使用例

カスタマイズされた TreeView の例を次に示しますTreeView クラス継承することにより、このカスタム バージョンには通常の TreeView機能すべてが備わってます。ここでは、コンストラクタさまざまなプロパティ値を変更して固有の外観にします。ShowPlusMinus プロパティfalse設定されるため、このカスタム コントロールは、ノードクリックされたときに展開または折りたたみ可能になるように、OnAfterSelect メソッドオーバーライドます。

このようにしてカスタマイズしたコントロール階層全体使用できるため、一貫性のあるインターフェイス簡単に作成できるようになりますプロジェクトごとにコントロールさまざまなプロパティ指定する要はありません。

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 'New


    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 'OnAfterSelect

End Class 'CustomizedTreeView
 
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 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 extends TreeView
{
    public CustomizedTreeView()
    {
        // Customize the TreeView control by setting various properties.
        set_BackColor(System.Drawing.Color.get_CadetBlue());
        set_FullRowSelect(true);
        set_HotTracking(true);
        set_Indent(34);
        set_ShowPlusMinus(false);
        // The ShowLines property must be false for the FullRowSelect
 
        // property to work.
        set_ShowLines(false);
    } //CustomizedTreeView

    protected 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.get_Action().Equals(TreeViewAction.Unknown)))
 {
            if (e.get_Node().get_IsExpanded()) {
                e.get_Node().Collapse();
            }
            else {
                e.get_Node().Expand();
            }
        }
        // Remove the selection. This allows the same node to be
        // clicked twice in succession to toggle the expansion state.
        set_SelectedNode(null);
    } //OnAfterSelect
}//CustomizedTreeView 
継承階層継承階層
System.Object
   System.EventArgs
    System.Windows.Forms.TreeViewEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
TreeViewEventArgs メンバ
System.Windows.Forms 名前空間
TreeViewCancelEventArgs クラス

TreeViewEventArgs コンストラクタ (TreeNode)


TreeViewEventArgs コンストラクタ

TreeViewEventArgs クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
TreeViewEventArgs (TreeNode) 対象となるツリー ノード指定してTreeViewEventArgs クラス新しインスタンス初期化します。
TreeViewEventArgs (TreeNode, TreeViewAction) 対象となるツリー ノードおよびイベント発生させたアクションの種類指定してTreeViewEventArgs クラス新しインスタンス初期化します。

.NET Compact Framework によってサポートされています。

参照参照

関連項目

TreeViewEventArgs クラス
TreeViewEventArgs メンバ
System.Windows.Forms 名前空間
TreeNode クラス

TreeViewEventArgs コンストラクタ (TreeNode, TreeViewAction)

対象となるツリー ノードおよびイベント発生させたアクションの種類指定して、TreeViewEventArgs クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    node As TreeNode, _
    action As TreeViewAction _
)
Dim node As TreeNode
Dim action As TreeViewAction

Dim instance As New TreeViewEventArgs(node,
 action)
public TreeViewEventArgs (
    TreeNode node,
    TreeViewAction action
)
public:
TreeViewEventArgs (
    TreeNode^ node, 
    TreeViewAction action
)
public TreeViewEventArgs (
    TreeNode node, 
    TreeViewAction action
)
public function TreeViewEventArgs (
    node : TreeNode, 
    action : TreeViewAction
)

パラメータ

node

イベント応答する対象の TreeNode。

action

イベント発生させた TreeViewAction の種類

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

TreeViewEventArgs プロパティ


TreeViewEventArgs メソッド


TreeViewEventArgs メンバ

TreeView コントロールの AfterCheck、AfterCollapse、AfterExpand、AfterSelect の各イベントデータ提供します

TreeViewEventArgs データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド TreeViewEventArgs オーバーロードされます。 TreeViewEventArgs クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

TreeViewEventArgs クラス
System.Windows.Forms 名前空間
TreeViewCancelEventArgs クラス



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「TreeViewEventArgs」の関連用語

TreeViewEventArgsのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



TreeViewEventArgsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS