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

Definición

Obtiene o establece el tamaño de la sangría de cada nivel de nodo de árbol secundario.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

Valor de propiedad

Tamaño, en píxeles, de la sangría de cada nivel de nodo de árbol secundario.The distance, in pixels, to indent each child tree node level. El valor predeterminado es 19.The default value is 19.

Excepciones

El valor asignado es menor que 0.The assigned value is less than 0.

O bien-or- El valor asignado es mayor que 32.000.The assigned value is greater than 32,000.

Ejemplos

En el ejemplo de código siguiente se ilustra una personalizada TreeView.The following code example illustrates a customized TreeView. Al heredar el TreeView (clase), esta versión personalizada tiene toda la funcionalidad de una típica TreeView.By inheriting the TreeView class, this custom version has all the functionality of a typical TreeView. Cambiar varios valores de propiedad en el constructor, proporciona una apariencia única.Changing various property values in the constructor provides a unique appearance. Dado que el ShowPlusMinus propiedad está establecida en false, el control personalizado también reemplaza el OnAfterSelect método para que los nodos se pueden expandir y contraer cuando se hace clic en.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.

Un control personalizado de esta manera puede usarse en toda la organización, facilitando el proceso proporcionar una interfaz coherente sin necesidad de las propiedades del control que se especifique en cada proyecto individual.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 

Comentarios

Establecer esta propiedad en un valor de -1 no produce una excepción si todavía no se ha cambiado el valor a su valor predeterminado.Setting this property to a value of -1 does not throw an exception if the value has not yet been changed from its default. Esto es porque el control utiliza un valor de -1 como un valor predeterminado interno antes de que se ha creado el identificador del control.This is because the control uses a value of -1 as an internal default before the control handle has been created. Este valor interno predeterminado hace que el control ajustado para devolver su propio valor predeterminado de 19.This internal default value causes the wrapped control to return its own default value of 19.

Se aplica a