internal static void AddChildNodes(NTreeNodeCollection collection, int siblingCount, ref int currDepth, int depth) { NTreeNode node; for (int i = 0; i < siblingCount; i++) { node = new NTreeNode(); node.Text = "Sample Tree Node " + i + "; Depth: " + currDepth; collection.Add(node); if (currDepth < depth) { currDepth++; AddChildNodes(node.Nodes, siblingCount, ref currDepth, depth); currDepth--; } } }
private void addSiblingBtn_Click(object sender, EventArgs e) { NTreeNode focused = nTreeViewEx1.FocusedItem as NTreeNode; if (focused == null) { return; } NTreeNodeCollection ownerNodes = focused.OwnerCollection as NTreeNodeCollection; if (ownerNodes == null) { return; } NTreeNode sibling = new NTreeNode(); sibling.Text = "Sibling " + ownerNodes.Count; ownerNodes.Insert(focused.Index + 1, sibling); sibling.Selected = true; }
internal static void AddTestNodes(NTreeViewEx tree, int siblingCount, int depth) { tree.Suspend(); tree.Nodes.Clear(); NTreeNode node; int currDepth = 0; NTreeNodeCollection currCollection = tree.Nodes; for (int i = 0; i < siblingCount; i++) { node = new NTreeNode(); node.Text = "Sample Tree Node " + i + "; Depth: " + currDepth; currDepth++; AddChildNodes(node.Nodes, siblingCount, ref currDepth, depth); currDepth--; currCollection.Add(node); } tree.Resume(true); }