Gets or sets the tree node that is currently selected in the tree view control.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
If no TreeNode is currently selected, the property is a null reference (Nothing in Visual Basic).
When you set this property, the specified node is scrolled into view and any parent nodes are expanded so that the specified node is visible.
When the parent node or any ancestor node of the selected node is collapsed either programmatically or through user action, the collapsed node becomes the selected node.
The following code example sets the PathSeparator property of a TreeView and displays the number of child tree nodes that is contained in the TreeNodeCollection of the . The percentage of child tree node to total tree nodes in the tree view control is also displayed. This example requires that you have a Form with a Button, and a TreeView control with a TreeNodeCollection that has several TreeNode objects (preferably with three or more levels).
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.