TreeView.Indent TreeView.Indent TreeView.Indent TreeView.Indent Property

정의

각 자식 트리 노드 수준을 들여 쓸 간격을 가져오거나 설정합니다.Gets or sets the distance to indent each child tree node level.

public:
 property int Indent { int get(); void set(int value); };
public int Indent { get; set; }
member this.Indent : int with get, set
Public Property Indent As Integer

속성 값

각 자식 트리 노드 수준을 들여 쓸 간격(픽셀)입니다.The distance, in pixels, to indent each child tree node level. 기본값은 19입니다.The default value is 19.

예외

할당 된 값이 0 보다 작은 경우The assigned value is less than 0.

또는-or- 할당 된 값이 32,000 보다 큽니다.The assigned value is greater than 32,000.

예제

다음 코드 예제에서는 사용자 지정 TreeView합니다.The following code example illustrates a customized TreeView. 상속 하 여 합니다 TreeView 클래스를 사용자 지정이 버전에 모든 기능의 일반적인 TreeView합니다.By inheriting the TreeView class, this custom version has all the functionality of a typical 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 that 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 '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 

설명

이 속성 값이-1 기본값에서 아직 변경 되지 않은 경우 예외를 throw 하지 않습니다.Setting this property to a value of -1 does not throw an exception if the value has not yet been changed from its default. 컨트롤이 컨트롤 핸들이 생성 되기 전에 내부 기본값으로-1 값을 사용 하는 때문입니다.This is because the control uses a value of -1 as an internal default before the control handle has been created. 이 내부 기본값 컨트롤이 래핑된 19의 자체 기본값을 반환 합니다.This internal default value causes the wrapped control to return its own default value of 19.

적용 대상