Priyanka
Priyanka

Reputation: 2832

how to get parent node index when parent node is inserted at runtime in treelist?

I've added parent node at runtime as

TreeListNode parentNode1 = treeList1.AppendNode(new object[] { "BuiltIn Groups"}, null);

But now i want to insert child node under particular parent node. In my application when user right click on particular parent node then i shown a menu & when user selects to insert new child node under selected parent node then i used the same treeList1.AppendNode() method but this method require second parameter as parent node index & i'm getting that parent node index when i insert parent node at run time.

Can u suggest something about this issue?

thanks.

Upvotes: 1

Views: 3152

Answers (2)

cdkMoose
cdkMoose

Reputation: 1636

If you want to insert a new child under the current selected node:

TreeNode parent = treeView.SelectedNode;

if (parent != null)
{
    treeList1.AppendNode(..., parent);
}

Upvotes: 3

DevExpress Team
DevExpress Team

Reputation: 11366

The following code should work for you:

    TreeListNode parentNode = treeList1.AppendNode(..., null);
    TreeListNode childNode = treeList1.AppendNode(..., parentNode);

Upvotes: 2

Related Questions