ParentNodeStyle Property

TreeView.ParentNodeStyle Property

 

Gets a reference to the TreeNodeStyle object that allows you to set the appearance of parent nodes in the TreeView control.

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

[<PersistenceModeAttribute(PersistenceMode.InnerProperty)>]
member ParentNodeStyle : TreeNodeStyle with get

Property Value

Type: System.Web.UI.WebControls.TreeNodeStyle

A reference to the TreeNodeStyle that represents the style of the parent nodes in the TreeView.

Use the ParentNodeStyle property to control the appearance of the parent nodes in the TreeView control. This property is read-only; however, you can set the properties of the TreeNodeStyle object it returns. The properties can be set declaratively in the form Property-Subproperty, where Subproperty is a property of the TreeNodeStyle object (for example, ParentNodeStyle-ForeColor). The properties can also be set programmatically in the form Property.Subproperty (for example, ParentNodeStyle.ForeColor). Common settings usually include a custom background color, foreground color, font properties, and node spacing. Style properties are applied in the following order of precedence:

  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.

If you need 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, you might consider using the LevelStyles property instead of setting the individual style properties.

The following code example demonstrates how to use the ParentNodeStyle property to control the appearance of the parent nodes in the TreeView control.

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

.NET Framework
Available since 2.0
Return to top
Show:
© 2016 Microsoft