Hi, I have a treeview (tri state with checkboxes) that I am using to represent some data. The way I initialize it is I first build all the nodes using loops, then I have a function that iterates though the nodes and marks certain ones checked = true as well as sets a backColor for others.
My question is I find it tedious to build it this way using for loops and was wondering if there is another easier way to build and maintain. Bascially I need to set it up to a default so it starts the same way each time, but the user at run time can modify it if needed.
What’s wrong with for each statement?
You might try DataBinding, http://www.codeproject.com/Articles/7884/Data-Binding-TreeView-in-C
I guess nothing since I only have to create it once. But I was thinking more in terms of making it easy to maintain in case there are modifications in the future to the default nodes and checkboxes. As well easy for someone to glance at the default pattern and know exactly the structure.
Thanks for the link I'll take a look.
Also what about XML document, would that be helpful?
You still need loops, see http://support.microsoft.com/kb/317597.
You still need the similar code to read the data and add one node by one node to the Treeview. Where the data come from doesn’t change this.
- Marked as answer by Bob Wu-MTModerator Monday, March 26, 2012 3:18 AM