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 クラス


このページでは「.NET Framework クラス ライブラリ リファレンス」からTreeViewEventArgs クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からTreeViewEventArgs クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からTreeViewEventArgs クラスを検索

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

辞書ショートカット

すべての辞書の索引

「TreeViewEventArgs クラス」の関連用語

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

   

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



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

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

©2024 GRAS Group, Inc.RSS