Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

TreeNodeStyleCollection Class

Note: This class is new in the .NET Framework version 2.0.

Represents a collection of TreeNodeStyle objects that is in a TreeView control.

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

public sealed class TreeNodeStyleCollection : StateManagedCollection
public final class TreeNodeStyleCollection extends StateManagedCollection
public final class TreeNodeStyleCollection extends StateManagedCollection

The TreeNodeStyleCollection class is used to store and manage a collection of TreeNodeStyle objects. The LevelStyles property, of type TreeNodeStyleCollection, stores the node styles for the individual levels of a tree.

The LevelStyles property is an alternative to the individual style properties, such as the NodeStyle property, that control node styles at different levels of the tree. The first style in the collection corresponds to the node style in the first level of the tree. The second style in the collection corresponds to the node style in the second level of the tree, and so on. The LevelStyles property is most often used to generate table of contents–style navigation menus where nodes at a certain level should have the same appearance, regardless of whether they have child nodes.

The TreeNodeStyleCollection class inherits most of its members from the StateManagedCollection class. For more information about the inherited members, see StateManagedCollection.

The following code example demonstrates how to use the TreeNodeStyleCollection class to specify the style settings for the individual levels of a TreeView control. Notice that the LevelStyles property returns a TreeNodeStyleCollection object.


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

<html>

  <body>
    <form runat="server">
    
      <h3>TreeView LevelStyles Example</h3>

      <!-- Populate the LevelStyles collection of the TreeView control -->
      <!-- declaratively.                                              -->
      
      <asp:TreeView id="LinksTreeView"
        Font-Name= "Arial"
        ForeColor="Blue"
        ShowExpandCollapse="false"
        InitialExpandDepth="3"
        NodeIndent="0" 
        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>

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


System.Object
   System.Web.UI.StateManagedCollection
    System.Web.UI.WebControls.TreeNodeStyleCollection
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.