TreeView.ShowCheckBoxes 속성

정의

TreeView 컨트롤에 확인란을 표시할 노드 형식을 나타내는 값을 가져오거나 설정합니다.

public:
 property System::Web::UI::WebControls::TreeNodeTypes ShowCheckBoxes { System::Web::UI::WebControls::TreeNodeTypes get(); void set(System::Web::UI::WebControls::TreeNodeTypes value); };
public System.Web.UI.WebControls.TreeNodeTypes ShowCheckBoxes { get; set; }
member this.ShowCheckBoxes : System.Web.UI.WebControls.TreeNodeTypes with get, set
Public Property ShowCheckBoxes As TreeNodeTypes

속성 값

TreeNodeTypes

TreeNodeTypes 값의 비트 조합입니다. 기본값은 TreeNodeType.None입니다.

예외

비트 조합 값이 TreeNodeTypes 열거형의 범위를 벗어난 경우

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 ShowCheckBoxes 속성을 표시 하 고 다른 노드 형식에 대 한 확인란을 숨깁니다.


<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  void Button_Click(Object sender, EventArgs e)
  {

    if(LinksTreeView.CheckedNodes.Count > 0)
    {

      // Clear the message label.
      Message.Text = "You selected: <br /><br />";

      // Iterate through the CheckedNodes collection and display the selected nodes.
      foreach (TreeNode node in LinksTreeView.CheckedNodes)
      {

        Message.Text += node.Text + "<br />";

      }

    }

    else
    {

      Message.Text = "No items selected.";

    }

  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeView ShowCheckBoxes Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView ShowCheckBoxes Example</h3>
    
      <!-- Set the ShowCheckBoxes property declaratively.   -->
      <!-- Because the ShowCheckBoxes property uses a flag  -->
      <!-- enumeration, you can combine multiple values by  -->
      <!-- using the bitwise OR operator. In declarative    -->
      <!-- syntax, this is done using a comma separated     -->
      <!-- list.                                            -->
      <asp:TreeView id="LinksTreeView"
        Font-Names= "Arial"
        ForeColor="Blue"
        ExpandDepth="2"
        ShowCheckBoxes="Parent,Leaf" 
        runat="server">
         
        <LevelStyles>
        
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Bold="true" 
            Font-Size="12pt" 
            ForeColor="DarkGreen"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-Bold="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-UnderLine="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Size="8pt"/>
             
        </LevelStyles>
         
        <Nodes>
        
          <asp:TreeNode Text="Table of Contents"
            SelectAction="None">
             
            <asp:TreeNode Text="Chapter One">
            
              <asp:TreeNode Text="Section 1.0">
              
                <asp:TreeNode Text="Topic 1.0.1"/>
                <asp:TreeNode Text="Topic 1.0.2"/>
                <asp:TreeNode Text="Topic 1.0.3"/>
              
              </asp:TreeNode>
              
              <asp:TreeNode Text="Section 1.1">
              
                <asp:TreeNode Text="Topic 1.1.1"/>
                <asp:TreeNode Text="Topic 1.1.2"/>
                <asp:TreeNode Text="Topic 1.1.3"/>
                <asp:TreeNode Text="Topic 1.1.4"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
            <asp:TreeNode Text="Chapter Two">
            
              <asp:TreeNode Text="Section 2.0">
              
                <asp:TreeNode Text="Topic 2.0.1"/>
                <asp:TreeNode Text="Topic 2.0.2"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
          </asp:TreeNode>
          <asp:TreeNode Text="Appendix A" />
          <asp:TreeNode Text="Appendix B" />
          <asp:TreeNode Text="Appendix C" />
        
        </Nodes>
        
      </asp:TreeView>
      
      <br /><br />
      
      <asp:Button id="Submit"
        Text="Select Items"
        OnClick="Button_Click"  
        runat="server"/>
         
      <br /><br />
      
      <asp:Label id="Message"
        runat="server"/>

    </form>
  </body>
</html>

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

  Sub Button_Click(ByVal sender As Object, ByVal e As EventArgs)

    If LinksTreeView.CheckedNodes.Count > 0 Then

      ' Clear the message label.
      Message.Text = "You selected: <br /><br />"

      ' Iterate through the CheckedNodes collection and display the selected nodes.
      Dim node As TreeNode
      
      For Each node In LinksTreeView.CheckedNodes

        Message.Text &= node.Text & "<br />"

      Next

    Else

      Message.Text = "No items selected."

    End If

  End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>TreeView ShowCheckBoxes Example</title>
</head>
<body>
    <form id="form1" runat="server">
    
      <h3>TreeView ShowCheckBoxes Example</h3>
    
      <!-- Set the ShowCheckBoxes property declaratively.   -->
      <!-- Because the ShowCheckBoxes property uses a flag  -->
      <!-- enumeration, you can combine multiple values by  -->
      <!-- using the bitwise OR operator. In declarative    -->
      <!-- syntax, this is done using a comma separated     -->
      <!-- list.                                            -->
      <asp:TreeView id="LinksTreeView"
        Font-Names= "Arial"
        ForeColor="Blue"
        ExpandDepth="2"
        ShowCheckBoxes="Parent,Leaf" 
        runat="server">
         
        <LevelStyles>
        
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Bold="true" 
            Font-Size="12pt" 
            ForeColor="DarkGreen"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-Bold="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="5" 
            Font-UnderLine="true" 
            Font-Size="10pt"/>
          <asp:TreeNodeStyle ChildNodesPadding="10" 
            Font-Size="8pt"/>
             
        </LevelStyles>
         
        <Nodes>
        
          <asp:TreeNode Text="Table of Contents"
            SelectAction="None">
             
            <asp:TreeNode Text="Chapter One">
            
              <asp:TreeNode Text="Section 1.0">
              
                <asp:TreeNode Text="Topic 1.0.1"/>
                <asp:TreeNode Text="Topic 1.0.2"/>
                <asp:TreeNode Text="Topic 1.0.3"/>
              
              </asp:TreeNode>
              
              <asp:TreeNode Text="Section 1.1">
              
                <asp:TreeNode Text="Topic 1.1.1"/>
                <asp:TreeNode Text="Topic 1.1.2"/>
                <asp:TreeNode Text="Topic 1.1.3"/>
                <asp:TreeNode Text="Topic 1.1.4"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
            <asp:TreeNode Text="Chapter Two">
            
              <asp:TreeNode Text="Section 2.0">
              
                <asp:TreeNode Text="Topic 2.0.1"/>
                <asp:TreeNode Text="Topic 2.0.2"/>
              
              </asp:TreeNode>
            
            </asp:TreeNode>
            
          </asp:TreeNode>
          <asp:TreeNode Text="Appendix A" />
          <asp:TreeNode Text="Appendix B" />
          <asp:TreeNode Text="Appendix C" />
        
        </Nodes>
        
      </asp:TreeView>
      
      <br /><br />
      
      <asp:Button id="Submit"
        Text="Select Items"
        OnClick="Button_Click"  
        runat="server"/>
         
      <br /><br />
      
      <asp:Label id="Message"
        runat="server"/>

    </form>
  </body>
</html>

설명

다중 노드 선택 지원을 제공할 수는 TreeView 제어 노드에 대 한 이미지 옆에 있는 확인란을 표시할 수 있습니다. 사용 된 ShowCheckBoxes 확인란을 표시할는 노드 형식을 지정 하는 속성입니다. 예를 들어가 속성이 TreeNodeType.Parent, 트리에서 각 부모 노드에 대 한 확인란이 표시 됩니다. 다음 표에서이 속성에 대 한 유효한 값을 나열합니다.

노드 형식 설명
TreeNodeType.All 모든 노드에 대 한 확인란이 표시 됩니다.
TreeNodeType.Leaf 모든 리프 노드에 대 한 확인란이 표시 됩니다.
TreeNodeType.None 확인란 표시 되지 않습니다.
TreeNodeType.Parent 모든 부모 노드에 대 한 확인란이 표시 됩니다.
TreeNodeType.Root 모든 루트 노드에 대 한 확인란이 표시 됩니다.

에 사용 되는 열거형은 ShowCheckBoxes 속성이 플래그 열거형을 비트 연산을 통해 값을 결합할 수 있습니다. 예를 들어, 부모 및 리프 노드에 대 한 확인란을 표시 하려면 사용 하 여 비트 OR 연산자를 결합 하 여 TreeNodeType.ParentTreeNodeType.Leaf 값입니다.

에 있는지 확인 하는 노드 해당 확인란의 노드를 반복을 선택 합니다 CheckedNodes 컬렉션입니다.

참고

재정의할 수 있습니다는 ShowCheckBoxes 설정 하 여 설정 된 ShowCheckBox 각 노드에 대 한 속성.

단일 선택만 지원을 제공 해야 할 경우 사용을 고려 합니다 SelectedNode 속성입니다.

이 속성의 값은 뷰 상태에 저장 됩니다.

적용 대상

추가 정보