You can control individually the styles for different types of the TreeView nodes – root nodes, nodes that contain other nodes, selected nodes, etc. You use the TreeView.NodeStyle property to apply node style settings to all the nodes of the tree. The next table lists more specific styles you can use to isolate individual regions of the TreeView:

C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development: Build applications with C#, .NET Core, Entity Framework Core, ASP.NET Core, and ML.NET using Visual Studio Code, 4th Edition
ASP.NET Core 3 and Angular 9: Full stack web development with .NET Core 3.1 and Angular 9, 3rd Edition
C# in Depth, 4th Edition






NodeStyle Applies to all nodes.
RootNodeStyle Applies only to the first-level (root) node.
ParentNodeStyle Applies to any node that contains other nodes, except root nodes.
LeafNodeStyle Applies to any node that doesn’t contain child nodes and isn’t a root node.
SelectedNodeStyle Applies to the currently selected node.

Applies to the node the user is hovering over with the mouse. These settings are applied only in up-level clients that support the necessary dynamic script.



Styles are listed in this table in order of most general to most specific. That means the SelectedNodeStyle style settings override any conflicting settings in a RootNodeStyle.  However, the RootNodeStyle, ParentNodeStyle, and LeafNodeStyle settings never conflict, because the definitions for root, parent, and leaf nodes are mutually exclusive. You can’t have a node that is simultaneously a parent and a root node, for example—the TreeView simply designates this as a root node.