Sorted (TreeView)

This property returns and sets a value that determines whether the child nodes of a Node object are sorted alphabetically. It also returns and sets a value that determines whether the root-level nodes of a TreeView control are sorted alphabetically.

Syntax

object.Sorted [= Boolean]

Parameters

object
Object expression that evaluates to an object.
Boolean
Boolean expression that specifies whether the Node objects are sorted.

Following are the settings for the Sorted property settings:

True
Node objects are sorted alphabetically by their Text property. Node objects whose Text property begins with a number are sorted as strings, with the first digit determining the initial position in the sort, and subsequent digits determining sub-sorting.
False
Node objects are not sorted.

Remarks

You can use the Sorted property in two ways: first, to sort the Node objects at the root (top) level of a TreeView control and second, to sort the immediate children of any individual Node object.

Setting the Sorted property to True sorts the current Nodes collection only. When you add new Node objects to a TreeView control, you must set the Sorted property to True again to sort the added Node objects.