TreeNodeStyle Class
Represents the style of a node in the TreeView control.
Assembly: System.Web (in System.Web.dll)
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 | Description |
|---|---|
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:
RootNodeStyle, ParentNodeStyle, or LeafNodeStyle, depending on the node type.
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.
- AspNetHostingPermission
for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
System::MarshalByRefObject
System.ComponentModel::Component
System.Web.UI.WebControls::Style
System.Web.UI.WebControls::TreeNodeStyle
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.