TreeView.ShowPlusMinus TreeView.ShowPlusMinus TreeView.ShowPlusMinus TreeView.ShowPlusMinus Property

Definición

Obtiene o establece un valor que indica si se muestran botones con los signos más (+) y menos (-) al lado de los nodos de árbol que contienen nodos de árbol secundarios.Gets or sets a value indicating whether plus-sign (+) and minus-sign (-) buttons are displayed next to tree nodes that contain child tree nodes.

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

Valor de propiedad

true Si se muestran los botones de signo más y signo menos junto a los nodos de árbol que contienen nodos de árbol secundarios; en caso contrario, false.true if plus sign and minus sign buttons are displayed next to tree nodes that contain child tree nodes; otherwise, false. De manera predeterminada, es true.The default is true.

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

Aparecen los botones de signo más y signo menos junto a solo si la nodos de árbol de raíz del ShowRootLines es el valor de propiedad true.The plus sign and minus sign buttons appear next to the root tree nodes only if the ShowRootLines property value is true. Si no se muestran los botones de signo más y signo menos, no hay ninguna indicación visual para indicar que el nodo de árbol contiene nodos de árbol secundarios y es expansible.If the plus sign and minus sign buttons are not displayed, no visual cue exists to indicate that the tree node contains child tree nodes and is expandable. El usuario, a continuación, debe haga doble clic en un nodo de árbol para determinar si contiene nodos de árbol secundarios, para expandirla o contraerla.The user then must double-click a tree node to determine whether it contains child tree nodes, to expand it, or to collapse it.

Se aplica a

Consulte también: