TreeView.Indent プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > TreeView.Indent プロパティの意味・解説 

TreeView.Indent プロパティ

ツリー ノードの各レベル設定するインデント幅を取得または設定します

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

<LocalizableAttribute(True)> _
Public Property Indent As
 Integer
Dim instance As TreeView
Dim value As Integer

value = instance.Indent

instance.Indent = value
[LocalizableAttribute(true)] 
public int Indent { get;
 set; }
[LocalizableAttribute(true)] 
public:
property int Indent {
    int get ();
    void set (int value);
}
/** @property */
public int get_Indent ()

/** @property */
public void set_Indent (int
 value)

プロパティ
ツリー ノードの各レベル設定するインデント幅 (ピクセル単位)。既定値は、19 です。

例外例外
例外種類条件

ArgumentOutOfRangeException

代入された値が 0 未満です (「解説」を参照)。

または

代入された値が 32,000超えてます。

解説解説
使用例使用例

カスタマイズされた 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 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

TreeView.Indent プロパティのお隣キーワード
検索ランキング

   

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



TreeView.Indent プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS