TreeView.ShowLines Propriété

Définition

Obtient ou définit une valeur indiquant si des lignes sont dessinées entre les nœuds d’arbre dans le contrôle arborescence.Gets or sets a value indicating whether lines are drawn between tree nodes in the tree view control.

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

Valeur de propriété

Boolean

true si des lignes sont dessinées entre les nœuds d'arbre dans le contrôle TreeView ; sinon, false.true if lines are drawn between tree nodes in the tree view control; otherwise, false. La valeur par défaut est true.The default is true.

Exemples

L’exemple de code suivant illustre un personnalisé TreeView .The following code example illustrates a customized TreeView. En héritant TreeView de la classe, cette version personnalisée possède toutes les fonctionnalités d’un type TreeView .By inheriting the TreeView class, this custom version has all the functionality of a typical TreeView. La modification de différentes valeurs de propriété dans le constructeur fournit une apparence unique.Changing various property values in the constructor provides a unique appearance. Étant donné que la ShowPlusMinus propriété a la valeur false, le contrôle personnalisé substitue également la OnAfterSelect méthode afin que les nœuds puissent être développés et réduits lorsque l’utilisateur clique dessus.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 contrôle personnalisé de cette façon peut être utilisé dans toute l’organisation, ce qui facilite la fourniture d’une interface cohérente sans que les propriétés du contrôle soient spécifiées dans chaque projet individuel.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


    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

Remarques

Si ShowLines a la valeur true , la FullRowSelect propriété est ignorée.If ShowLines is set to true, the FullRowSelect property is ignored.

S’applique à