TreeView.Indent Özellik

Tanım

Her alt ağaç düğümü düzeyini girintili hale getirmek için uzaklığı alır veya ayarlar.

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

Özellik Değeri

Int32

Her alt ağaç düğümü düzeyini girintili yapmak için piksel cinsinden uzaklık. Varsayılan değer 19'dur.

Özel durumlar

Atanan değer 0'dan küçük.

-veya-

Atanan değer 32.000'den büyük.

Örnekler

Aşağıdaki kod örneğinde özelleştirilmiş TreeViewbir gösterilmektedir. Sınıfı devralarak TreeView , bu özel sürüm tipik TreeViewbir işlevinin tüm işlevlerine sahiptir. Oluşturucudaki çeşitli özellik değerlerinin değiştirilmesi benzersiz bir görünüm sağlar. ShowPlusMinus özelliği false olarak ayarlandığından, özelleştirilmiş denetim de yöntemi geçersiz kılar, böylece düğümler OnAfterSelect tıklandığında genişletilebilir ve daraltılabilir.

Bu şekilde özelleştirilmiş bir denetim kuruluş genelinde kullanılabilir ve her bir projede denetim özelliklerinin belirtilmesine gerek kalmadan tutarlı bir arabirim sağlamayı kolaylaştırır.

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


    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

End Class

Açıklamalar

Bu özelliğin -1 değerine ayarlanması, değer henüz varsayılan değerden değiştirilmediyse özel durum oluşturmaz. Bunun nedeni, denetimin denetim tutamacı oluşturulmadan önce iç varsayılan olarak -1 değerini kullanmasıdır. Bu iç varsayılan değer, sarmalanan denetimin kendi varsayılan değeri olan 19'un döndürülmesine neden olur.

Şunlara uygulanır