Share via


TreeView.ShowPlusMinus Özellik

Tanım

Alt ağaç düğümleri içeren ağaç düğümlerinin yanında artı işareti (+) ve eksi işareti (-) düğmelerinin görüntülenip görüntülenmeyeceğini belirten bir değer alır veya ayarlar.

public:
 property bool ShowPlusMinus { bool get(); void set(bool value); };
public bool ShowPlusMinus { get; set; }
member this.ShowPlusMinus : bool with get, set
Public Property ShowPlusMinus As Boolean

Özellik Değeri

true alt ağaç düğümleri içeren ağaç düğümlerinin yanında artı işareti ve eksi işareti düğmeleri görüntüleniyorsa; aksi takdirde , false. Varsayılan değer: true.

Örnekler

Aşağıdaki kod örneğinde özelleştirilmiş TreeViewbir gösterilmektedir. sınıfını TreeView devralarak, 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

Artı işareti ve eksi işareti düğmeleri, yalnızca özellik değeri trueise kök ağaç düğümlerinin ShowRootLines yanında görünür. Artı işareti ve eksi işareti düğmeleri görüntülenmiyorsa, ağaç düğümlerinin alt ağaç düğümleri içerdiğini ve genişletilebilir olduğunu belirten bir görsel ipucu yoktur. Daha sonra kullanıcının alt ağaç düğümleri içerdiğini belirlemek, genişletmek veya daraltmak için bir ağaç düğümüne çift tıklaması gerekir.

Şunlara uygulanır

Ayrıca bkz.