sternaphile
July 22nd, 2002, 01:32 PM
I'm using TreeView in an app, and I'm trying to Insert a new node into a specific area in the tree. I'm trying to insert it under it's parent, but it keeps being inserted at a level equal to the 'root'.
What am I doing wrong??
.
.
.
// Get currently selected node and make a new name for child.
TreeNode ThisNode = LeftTreeView.SelectedNode;
String str2 = ThisNode.Text + "_child";
// Create a new node.
TreeNode NewNode = new TreeNode(str2);
// Get index of parent node.
int nIdx = -1;
nIdx = ThisNode.Index;
// Bump index and insert NewNode directly under parent.
LeftTreeView.Nodes.Insert(nIdx+1, NewNode);
.
.
.
Thanks for your help
:confused: :confused: :confused: :confused: :confused: :confused:
What am I doing wrong??
.
.
.
// Get currently selected node and make a new name for child.
TreeNode ThisNode = LeftTreeView.SelectedNode;
String str2 = ThisNode.Text + "_child";
// Create a new node.
TreeNode NewNode = new TreeNode(str2);
// Get index of parent node.
int nIdx = -1;
nIdx = ThisNode.Index;
// Bump index and insert NewNode directly under parent.
LeftTreeView.Nodes.Insert(nIdx+1, NewNode);
.
.
.
Thanks for your help
:confused: :confused: :confused: :confused: :confused: :confused: