TreeNode Constructor (String, TreeNode[])


Initializes a new instance of the TreeNode class with the specified label text and child tree nodes.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

new : 
        text:string *
        children:TreeNode[] -> TreeNode


Type: System.String

The label Text of the new tree node.

Type: System.Windows.Forms.TreeNode[]

An array of child TreeNode objects.

The text parameter value is assigned to the node's Text property and becomes the tree node label. The tree nodes that are contained in the children array are added to the TreeNodeCollection that is stored in the Nodes property.

The following code example creates a root tree node to assign child tree nodes to. A child tree node for each Customer object in an ArrayList is added to the root tree node as well as a child tree node for each Order object assigned to the Customer object. The Customer object is assigned to the Tag property, and the tree nodes representing Customer objects are displayed with Orange text. This example requires that you have a Customer and Order object defined, a TreeView control on a Form, and an ArrayList named customerArray that contains Customer objects.

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

.NET Framework
Available since 1.1
Return to top