By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,155 Members | 952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,155 IT Pros & Developers. It's quick & easy.

Treeview Control - and saving it's nodes...

P: n/a
Hi All,

I'm eagerly anticipating what you have to say on something that's
stumped me over the weekend. I'm writing a small application which
utilises a treeview control. I've figured out how to programatically
add nodes to it, but everytime the program is exited the treeview
control resets itself.

I looked for a save method or something similair but there doesn't seem
to be one. I have found the copyto method, and figured out how to copy
the treeview collection to an array however!

So I thought i could write this array to a file, and read it at runtime
to populate the treeview, however when I enumerate the array I only get
the parant nodes. And when I use the rank method It tells me the array
is one dimensional.

So my question is twofold really. One, am I going about this the right
way or is there a better way to save the treeview collection? And two,
how do I copy the entire treeview collection to an array, and not just
the parant nodes?

Many thanks, and in anticipation!


Mar 27 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a
In case anyone is reading this and needs help with the treeview control
and saving it's content. I have found the answer. Firstly to get the
entire tree view, you first create an 'arraylist' and then add all the
nodes to the treeview. al in the code below is the name of an

foreach (TreeNode tn in tree.Nodes)
// add every treenode in tree.nodes to the array

and how do you save this to a file? The answer is something called
serialisation, it's exactly the answer what I needed - so read up on it
if you need to save a treeview. It lets you write a complex object to a

Nice when it all clicks into place!

Mar 27 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.