Export (0) Print
Expand All

TreeNodeStyleCollection Class

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

System.Object
  System.Web.UI.StateManagedCollection
    System.Web.UI.WebControls.TreeNodeStyleCollection

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

public sealed class TreeNodeStyleCollection : StateManagedCollection

The TreeNodeStyleCollection type exposes the following members.

  NameDescription
Public propertyCountGets the number of elements contained in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public propertyItemGets or sets the TreeNodeStyle object at the specified index in the TreeNodeStyleCollection object.
Top

  NameDescription
Public methodAddAppends the specified TreeNodeStyle object to the end of the TreeNodeStyleCollection object.
Public methodClearRemoves all items from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public methodContainsDetermines whether the specified TreeNodeStyle object is in the collection.
Public methodCopyTo(Array, Int32)Copies the elements of the StateManagedCollection collection to an array, starting at a particular array index. (Inherited from StateManagedCollection.)
Public methodCopyTo(TreeNodeStyle[], Int32)Copies all the items from the TreeNodeStyleCollection object to a compatible one-dimensional array of TreeNodeStyle objects, starting at the specified index in the target array.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetEnumeratorReturns an iterator that iterates through the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIndexOfDetermines the index of the specified TreeNodeStyle object in the collection.
Public methodInsertInserts the specified TreeNodeStyle object into the TreeNodeStyleCollection object at the specified index location.
Public methodRemoveRemoves the specified TreeNodeStyle object from the TreeNodeStyleCollection object.
Public methodRemoveAtRemoves the TreeNodeStyle object at the specified index location from the TreeNodeStyleCollection object.
Public methodSetDirtyForces the entire StateManagedCollection collection to be serialized into view state. (Inherited from StateManagedCollection.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate propertyICollection.CountInfrastructure. Gets the number of elements contained in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyICollection.IsSynchronizedInfrastructure. Gets a value indicating whether the StateManagedCollection collection is synchronized (thread safe). This method returns false in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyICollection.SyncRootInfrastructure. Gets an object that can be used to synchronize access to the StateManagedCollection collection. This method returns null in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIEnumerable.GetEnumeratorInfrastructure. Returns an iterator that iterates through the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.AddAdds an item to the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.ClearInfrastructure. Removes all items from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.ContainsDetermines whether the StateManagedCollection collection contains a specific value. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.IndexOfDetermines the index of a specified item in the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.InsertInserts an item into the StateManagedCollection collection at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList.IsFixedSizeInfrastructure. Gets a value indicating whether the StateManagedCollection collection has a fixed size. This method returns false in all cases. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList.IsReadOnlyInfrastructure. Gets a value indicating whether the StateManagedCollection collection is read-only. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIList.ItemInfrastructure. Gets the IStateManager element at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.RemoveRemoves the first occurrence of the specified object from the StateManagedCollection collection. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIList.RemoveAtRemoves the IStateManager element at the specified index. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate propertyIStateManager.IsTrackingViewStateGets a value indicating whether the StateManagedCollection collection is saving changes to its view state. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager.LoadViewStateRestores the previously saved view state of the StateManagedCollection collection and the IStateManager items it contains. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager.SaveViewStateSaves the changes to the StateManagedCollection collection and each IStateManager object it contains since the time the page was posted back to the server. (Inherited from StateManagedCollection.)
Explicit interface implemetationPrivate methodIStateManager.TrackViewStateCauses the StateManagedCollection collection and each of the IStateManager objects it contains to track changes to their view state so they can be persisted across requests for the same page. (Inherited from StateManagedCollection.)
Top

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#" %>

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

  <head runat="server">
    <title>TreeView LevelStyles Example</title>
</head>
<body>
    <form id="form1" runat="server">

      <h3>TreeView LevelStyles Example</h3>

      <!-- Populate the LevelStyles collection of the TreeView control -->
      <!-- declaratively.                                              -->

      <asp:TreeView id="LinksTreeView"
        Font-Names= "Arial"
        ForeColor="Blue"
        ShowExpandCollapse="false"
        ExpandDepth="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>

.NET Framework

Supported in: 4.5.3, 4, 3.5, 3.0, 2.0

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft