다음을 통해 공유


TreeView.ShowPlusMinus 속성

자식 트리 노드를 포함하는 트리 노드 옆에 더하기 기호(+) 및 빼기 기호(-) 단추가 표시되는지 여부를 나타내는 값을 가져오거나 설정합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Property ShowPlusMinus As Boolean
‘사용 방법
Dim instance As TreeView
Dim value As Boolean

value = instance.ShowPlusMinus

instance.ShowPlusMinus = value
public bool ShowPlusMinus { get; set; }
public:
property bool ShowPlusMinus {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_ShowPlusMinus ()

/** @property */
public void set_ShowPlusMinus (boolean value)
public function get ShowPlusMinus () : boolean

public function set ShowPlusMinus (value : boolean)

속성 값

자식 트리 노드를 포함하는 트리 노드 옆에 더하기 기호 및 빼기 기호 단추가 표시되면 true이고, 그렇지 않으면 false입니다. 기본값은 true입니다.

설명

ShowRootLines 속성 값이 true인 경우에만 루트 트리 노드 옆에 더하기 기호 및 빼기 기호 단추가 표시됩니다. 더하기 기호 및 빼기 기호 단추가 표시되지 않으면 트리 노드에 자식 트리 노드가 포함되는지와 트리 노드가 확장 가능한지를 시각적으로 구분할 수 없습니다. 그런 경우 트리 노드를 두 번 클릭하여 해당 트리 노드에 확장 및 축소할 수 있는 자식 트리 노드가 들어 있는지 여부를 확인해야 합니다.

예제

다음 코드 예제에서는 사용자 지정된 TreeView를 보여 줍니다. 이 사용자 지정 버전은 TreeView 클래스를 상속함으로써 일반적인 TreeView의 모든 기능을 갖습니다. 생성자의 다양한 속성 값을 변경하여 고유한 모양을 만들 수 있습니다. ShowPlusMinus 속성이 false로 설정되어 있으므로 이 사용자 지정된 컨트롤은 노드를 클릭할 때 노드가 확장되거나 축소될 수 있도록 OnAfterSelect 메서드도 재정의합니다.

이 방법으로 사용자 지정된 컨트롤을 조직 전체에서 사용하면 각각의 개별 프로젝트에서 컨트롤 속성을 지정하지 않고도 일관된 인터페이스를 쉽게 제공할 수 있습니다.

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 
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 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 extends TreeView
{
    public CustomizedTreeView()
    {
        // Customize the TreeView control by setting various properties.
        set_BackColor(System.Drawing.Color.get_CadetBlue());
        set_FullRowSelect(true);
        set_HotTracking(true);
        set_Indent(34);
        set_ShowPlusMinus(false);
        // The ShowLines property must be false for the FullRowSelect 
        // property to work.
        set_ShowLines(false);
    } //CustomizedTreeView

    protected 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.get_Action().Equals(TreeViewAction.Unknown))) {
            if (e.get_Node().get_IsExpanded()) {
                e.get_Node().Collapse();
            }
            else {
                e.get_Node().Expand();
            }
        }
        // Remove the selection. This allows the same node to be
        // clicked twice in succession to toggle the expansion state.
        set_SelectedNode(null);
    } //OnAfterSelect
}//CustomizedTreeView 

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

TreeView 클래스
TreeView 멤버
System.Windows.Forms 네임스페이스
ShowRootLines