开发者

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

开发者 https://www.devze.com 2023-03-01 13:53 出处:网络
I\'ve added parent node at runtime as TreeListNode parentNode1 = treeList1.AppendNode(new object[] { \"BuiltIn Groups\"}, null);

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 p开发者_StackOverflow中文版arent 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.


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

TreeNode parent = treeView.SelectedNode;

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


The following code should work for you:

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

精彩评论

暂无评论...
验证码 换一张
取 消