This documentation is archived and is not being maintained.

TreeNodeTypes Enumeration

Represents the different node types (leaf, parent, and root) in the TreeView control.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public enum TreeNodeTypes

Member nameDescription
NoneNo nodes.
RootA node with no parent node and one or more child nodes.
ParentA node with a parent node and one or more child nodes.
LeafA node with no child nodes.
AllAll nodes.

The TreeNodeTypes enumeration is used to represent the different node types that are available in the TreeView control. The following table describes the three different node types.

Node type



A node with no child nodes.


A node with a parent node and one or more child nodes.


A node with no parent node and one or more child nodes.

The TreeNodeTypes enumeration is a flag enumeration, which allows you to combine values through bitwise operations. For example, to represent the parent and leaf nodes, you can perform a bitwise OR operation on the Parent and Leaf values.


The ShowCheckBoxes property uses the TreeNodeTypes enumeration to represent the node types that display check boxes in the TreeView control. When it is set to a value other than the None value, check boxes are displayed next to the specified node type, which allows users to select multiple items from the TreeView control.

The following code 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" 
<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 />";




      Message.Text = "No items selected.";




<html xmlns="" >
  <head runat="server">
    <title>TreeView ShowCheckBoxes Example</title>
    <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"


          <asp:TreeNodeStyle ChildNodesPadding="10" 
          <asp:TreeNodeStyle ChildNodesPadding="5" 
          <asp:TreeNodeStyle ChildNodesPadding="5" 
          <asp:TreeNodeStyle ChildNodesPadding="10" 



          <asp:TreeNode Text="Table of Contents"

            <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 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 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 Text="Appendix A" />
          <asp:TreeNode Text="Appendix B" />
          <asp:TreeNode Text="Appendix C" />



      <br /><br />

      <asp:Button id="Submit"
        Text="Select Items"

      <br /><br />

      <asp:Label id="Message"


Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0