This documentation is archived and is not being maintained.

TreeNodeStyle Class

Represents the style of a node in the TreeView control.

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

[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class TreeNodeStyle sealed : public Style

Use the TreeNodeStyle class to represent the style of a node in the TreeView control. The TreeView control allows you to specify different style characteristics (such as font size and color) for each of the different node types.

The following table lists the node styles that are supported by the TreeNodeStyle class.

Node style property



The style settings for a node when the mouse pointer is positioned over it.


The style settings for the leaf nodes.


The default style settings for a node.


The style settings for the parent nodes.


The style settings for the root node.


The style settings for a selected node.

When you set the node style properties of the TreeView control, they are applied in the following order:

  1. NodeStyle.

  2. RootNodeStyle, ParentNodeStyle, or LeafNodeStyle, depending on the node type.

  3. LevelStyles.

  4. SelectedNodeStyle.

  5. HoverNodeStyle.

The TreeNodeStyle class inherits most of its members from the Style class. It extends the Style class by providing properties that control the amount of space around the text in a node, as well as the space between adjacent nodes. Use the HorizontalPadding property to control the amount of space to the left and right of the text in a node. Similarly, the VerticalPadding property controls the amount of space above and below the text in a node. You can control the amount of spacing between the node that the TreeNodeStyle is applied to and its adjacent nodes by setting the NodeSpacing property. To control the amount of spacing between a parent node and a child node, use the ChildNodesPadding property.

For more information about the inherited style settings, see Style.

The following code example demonstrates how to control the appearance of the parent nodes in the TreeView control by setting the style properties of the TreeNodeStyle object that is returned from the ParentNodeStyle property.

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

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 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0