Treeview: reference a Treenode using a string

D

dillon_99

Hello,

I have been working with the treeview control from Microsoft.

Here is what I want to do:

I have a function that returns a string:

private string generateNodeString(ArrayList array) {
string ReturnVar = "myTreeview.Nodes[0]";
int i;
for (i=1;i<array.Count-1;i++) {
ReturnVar += ".Nodes[" + array.ToString() + "]";
}
return ReturnVar;
}


this would return me a "string" in the format of:

myTreeview.Nodes[0].Nodes[0].Nodes[0].Nodes[3]

I am then trying to pass this string in as an argument of a
treeNode.Add function (that part is already working).

private void AddTreeNode(TreeNodeCollection nodes, string nodeText,
string url)
{
nodes.Add(Node(nodeText, url));
}
private TreeNode Node(string text, string url)
{
TreeNode n = new TreeNode();
n.Text = text;
n.NavigateUrl = url;
return n;
}

how do i pass the string in, and make the system recognize it as a
Treenode (treecollection object)?

any help would be appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top