TreeView.ShowLines TreeView.ShowLines TreeView.ShowLines TreeView.ShowLines Property

정의

트리 뷰 컨트롤의 트리 노드 사이에 선이 그려졌는지를 나타내는 값을 가져오거나 설정합니다.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

속성 값

true 트리 뷰 컨트롤의 트리 노드 사이 선이 그려는 경우 그렇지 않으면 false합니다.true if lines are drawn between tree nodes in the tree view control; otherwise, false. 기본값은 true입니다.The default is true.

예제

다음 코드 예제에서는 사용자 지정 TreeView합니다.The following code example illustrates a customized TreeView. 상속 하 여 합니다 TreeView 클래스를 사용자 지정이 버전에 모든 기능의 일반적인 TreeView합니다.By inheriting the TreeView class, this custom version has all the functionality of a typical TreeView. 생성자에서 다양 한 속성 값 변경에 고유한 모양을 제공 합니다.Changing various property values in the constructor provides a unique appearance. 때문에 합니다 ShowPlusMinus 속성이 false로 설정 되어, 사용자 지정된 컨트롤 재정의 OnAfterSelect 메서드 노드를 확장 하 고 클릭할 때 축소 될 수 있도록 합니다.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.

이러한 방식으로 사용자 지정 된 컨트롤을 쉽게 컨트롤 속성을 개별 프로젝트 각각 지정 하지 않고도 일관 된 인터페이스를 제공 하는 조직 전반에 걸쳐 사용할 수 있습니다.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 

설명

하는 경우 ShowLines 로 설정 된 trueFullRowSelect 속성은 무시 됩니다.If ShowLines is set to true, the FullRowSelect property is ignored.

적용 대상