TreeView.LevelStyles Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets a collection of Style objects that represent the node styles at the individual levels of the tree.

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

[<PersistenceModeAttribute(PersistenceMode.InnerProperty)>]
member LevelStyles : TreeNodeStyleCollection with get

Property Value

Type: System.Web.UI.WebControls.TreeNodeStyleCollection

A StyleCollection that represents the node styles at the individual levels of the tree.

Use the LevelStyles collection as an alternative to the individual style properties (such as the NodeStyle property) to control the style of nodes at the individual levels of the tree. The first style in the collection corresponds to the style of nodes in the first level of the tree. The second style in the collection corresponds to the style of nodes in the second level of the tree, and so on. This 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.

Style properties are applied in the following order:

  1. NodeStyle.

  2. RootNodeStyle, ParentNodeStyle, or LeafNodeStyle, depending on the node type. If the LevelStyles collection is defined, it is applied at this time, overriding the other node style properties.

  3. SelectedNodeStyle.

  4. HoverNodeStyle

The following code example demonstrates how to use the LevelStyles property to create a navigation menu. The control is always fully expanded, with the expansion node indicators and images hidden. Also, the ChildNodesPadding property is used to control the spacing of the node levels.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: