TreeNodeTypes TreeNodeTypes TreeNodeTypes TreeNodeTypes Enum

Definition

Stellt die verschiedenen Knotentypen (Endknoten, übergeordneter Knoten und Stammknoten) im TreeView-Steuerelement dar.Represents the different node types (leaf, parent, and root) in the TreeView control.

Diese Enumeration weist ein FlagsAttribute-Attribut auf, die eine bitweise Kombination der Memberwerte zulässt.

public enum class TreeNodeTypes
[System.Flags]
public enum TreeNodeTypes
type TreeNodeTypes = 
Public Enum TreeNodeTypes
Vererbung
TreeNodeTypesTreeNodeTypesTreeNodeTypesTreeNodeTypes
Attribute

Felder

All All All All 7

Alle Knoten.All nodes.

Leaf Leaf Leaf Leaf 4

Ein Knoten ohne untergeordnete Knoten.A node with no child nodes.

None None None None 0

Keine Knoten.No nodes.

Parent Parent Parent Parent 2

Ein Knoten mit einem übergeordneten Knoten und mindestens einem untergeordneten Knoten.A node with a parent node and one or more child nodes.

Root Root Root Root 1

Ein Knoten ohne übergeordneten Knoten und mit mindestens einem untergeordneten Knoten.A node with no parent node and one or more child nodes.

Beispiele

Im folgenden Beispiel wird veranschaulicht, wie die TreeNodeTypes -Enumeration verwendet wird, TreeView um anzugeben, dass das-Steuerelement nur ein Kontrollkästchen für die einzelnen übergeordneten Knoten und Blattknoten anzeigen soll:The following example demonstrates how to use the TreeNodeTypes enumeration to indicate that the TreeView control should show a check box for each of the parent and leaf nodes only:


<%@ 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>

Hinweise

Die TreeNodeTypes -Enumeration wird verwendet, um die verschiedenen Knoten Typen darzustellen, die TreeView im-Steuerelement verfügbar sind.The TreeNodeTypes enumeration is used to represent the different node types that are available in the TreeView control. In der folgenden Tabelle werden die drei verschiedenen Knoten Typen beschrieben:The following table describes the three different node types:

KnotentypNode type BeschreibungDescription
Leaf Ein Knoten ohne untergeordnete Knoten.A node with no child nodes.
Parent Ein Knoten mit einem übergeordneten Knoten und mindestens einem untergeordneten Knoten.A node with a parent node and one or more child nodes.
Root Ein Knoten ohne übergeordneten Knoten und mit mindestens einem untergeordneten Knoten.A node with no parent node and one or more child nodes.

Die TreeNodeTypes -Enumeration ist eine Flag-Enumeration, die es Ihnen ermöglicht, Werte durch bitweise Vorgänge zu kombinieren.The TreeNodeTypes enumeration is a flag enumeration, which allows you to combine values through bitwise operations. Um z. b. die übergeordneten Knoten und die Blattknoten darzustellen, können Sie eine OR bitweise- Parent Operation Leaf für den-Wert und den-Wert ausführen.For example, to represent the parent and leaf nodes, you can perform a bitwise OR operation on the Parent and Leaf values.

Hinweis

Die TreeView.ShowCheckBoxes -Eigenschaft verwendet TreeNodeTypes die-Enumeration, um die Knoten Typen darzustellen, die Kontroll TreeView Kästchen im-Steuerelement anzeigen.The TreeView.ShowCheckBoxes property uses the TreeNodeTypes enumeration to represent the node types that display check boxes in the TreeView control. Wenn der Wert auf einen anderen Wert als Nonefestgelegt ist, werden neben dem angegebenen Knotentyp Kontrollkästchen angezeigt, die es Benutzern ermöglichen, mehrere Elemente aus dem TreeView Steuerelement auszuwählen.When it is set to a value other than None, check boxes are displayed next to the specified node type, which allows users to select multiple items from the TreeView control.

Gilt für:

Siehe auch