I have an input stream something like this:
John
Peter
Vanesa
Vanesa.New
Josh
Josh.New
Josh.New.Under
...
I need to Add Nodes to TreeView Someting like this:
+Customers
+John
+Peter
+Vanesa
+New
+Josh
+New
+Under
...
I have an idea to split every string with parameter '.', but i have a problem with dynamicly loaded nodes. Maybe i have to use some kind of foreach...
I have old database table "group" with records id and GroupName. The are filled with these strings. I need to create some kind of "address" like: John.Element or Vanesa.New.Element or Josh.New.Under.Element, where Element is record from other datatable. The DB connection is not the problem, the problem is the dynamicly fill the tree
For now i have done adding strings that don't contains '.':
reader = readGroups.ExecuteNonQuery();
while(reader.Read())
{
string[] buff = reader.GetValue(1).ToString().Split('.');
if (buff.Length == 1)
{
treeView1.Nodes[0].Nodes.Add(reader.GetValue(1));
}
else
{
//group contains '.'
}
}
EDIT: I have one more problem. There is records like this: John, John.New, John.Old, John.Older, John.Oldest ... So when the AddNodes() method runs, the foreach in the end of the method clears John.New, John.Old, John.Older nodes, but they got to go into the treenode John. If you have some idea...