System.Web.UI.WebControls Namespace TreeView Class
.NET Framework version 2.0
Returns a collection of TreeNodeStyle objects that represent the node styles at the individual levels of a TreeView control.
Inline |
<asp:treeview levelstyles = value ... > |
Script |
TreeView.LevelStyles [ = value ] |
The property is read/write with no default value.
Use the LevelStyles collection as an alternative to using the NodeStyle, RootNodeStyle, ParentNodeStyle, or LeafNodeStyle properties to control the style of TreeView nodes at the individual levels of the tree structure.
The styles contained in this collection are applied to the nodes based on their level in 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 collection is most often used to generate a table of contents-style navigation TreeView where nodes at a certain level should have the same appearance.
NOTE: If a style is defined for a certain level using the LevelStyles collection, this overrides any node style settings at that level.
The following example shows how to use the LevelStyles collection to apply style settings to the nodes in a TreeView control based on their level.
<asp:treeview id = "myTreeView" runat = "server"
datasourceid = "siteMap"
nodeindent=0
expanddepth=1>
<levelstyles>
<asp:treenodestyle width=100%
font-size = "10pt" font-bold
verticalpadding=3
backcolor = "steelblue"
forecolor = "beige"
borderwidth=1
borderstyle = "outset" />
<asp:treenodestyle width=100%
font-size = "10pt" font-bold
verticalpadding=3
backcolor = "steelblue"
forecolor = "beige"
borderwidth=1
borderstyle = "outset" />
<asp:treenodestyle width=100%
font-size = "9pt"
backcolor = "ghostwhite"
forecolor = "maroon" />
<asp:treenodestyle width=100%
font-size = "8pt"
backcolor = "whitesmoke" />
</levelstyles>
</asp:treeview>
<asp:sitemapdatasource id = "siteMap" runat = "server" />
Show me
TreeView Members