TreeView.ShowPlusMinus Eigenschap

Definitie

Hiermee wordt een waarde opgehaald of ingesteld die aangeeft of de knoppen plusteken (+) en minteken (-) worden weergegeven naast structuurknooppunten die onderliggende boomknooppunten bevatten.

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

Waarde van eigenschap

true als plus- en mintekenknoppen worden weergegeven naast boomknooppunten die onderliggende boomknooppunten bevatten; anders, false. De standaardwaarde is true.

Voorbeelden

In het volgende codevoorbeeld ziet u een aangepaste TreeViewafbeelding. Door de TreeView klasse over te nemen, heeft deze aangepaste versie alle functionaliteit van een typische TreeViewversie. Het wijzigen van verschillende eigenschapswaarden in de constructor biedt een uniek uiterlijk. Omdat de ShowPlusMinus eigenschap is ingesteld op false, overschrijft het aangepaste besturingselement ook de OnAfterSelect methode, zodat knooppunten kunnen worden uitgevouwen en samengevouwen wanneer erop wordt geklikt.

Een besturingselement dat op deze manier is aangepast, kan in een organisatie worden gebruikt, waardoor het eenvoudig is om een consistente interface te bieden zonder dat de besturingseigenschappen in elk afzonderlijk project moeten worden opgegeven.

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

Opmerkingen

De plusteken- en mintekenknoppen worden alleen naast de hoofdstructuurknooppunten weergegeven als de ShowRootLines eigenschapswaarde is true. Als het plusteken en het minteken niet worden weergegeven, bestaat er geen visuele aanwijzing om aan te geven dat het structuurknooppunt onderliggende boomknooppunten bevat en kan worden uitgebreid. De gebruiker moet vervolgens dubbelklikken op een structuurknooppunt om te bepalen of het onderliggende structuurknooppunten bevat, om het uit te vouwen of om het samen te vouwen.

Van toepassing op

Zie ook