Thanks Nicholas,
I ask this question because I have been looking at a lot of example code
within the
last week. And it's really confusing the way the tree is being stored to
whatever
storage is being used, and restored with the same exact layout still remains
a
mystery to me. I see no where in anyone's code where they are storing node
names,
levels, nothing. Here is an example I found last night, but even after
debugging and
looking at the values, I still can't see anything at all that shows me the
exact layout of
a tree.
void SaveTreeView(Tr eeView tree, string filename)
{
ArrayList al = new ArrayList();
foreach (TreeNode tn in tree.Nodes)
{
al.Add(node);
//listBox.Items.A dd(node.Text + "," + depth);
}
Stream file = File.Open(filen ame, FileMode.Create );
BinaryFormatter bf = new BinaryFormatter ();
try
{
bf.Serialize(fi le, al);
}
catch (System.Runtime .Serialization. SerializationEx ception e)
{
MessageBox.Show ("Serializat ion failed : {0}", e.Message);
}
file.Close();
}
void LoadTreeView(Tr eeView tree, string filename)
{
if (File.Exists(fi lename))
{
Stream file = File.Open(filen ame, FileMode.Open);
BinaryFormatter bf = new BinaryFormatter ();
object obj = null;
try
{
obj = bf.Deserialize( file);
}
catch (System.Runtime .Serialization. SerializationEx ception
e)
{
MessageBox.Show ("De-Serialization failed : {0}",
e.Message);
}
file.Close();
ArrayList nodeList = obj as ArrayList;
// load Root-Nodes
foreach (TreeNode node in nodeList)
{
tree.Nodes.Add( node);
//listBox.Items.A dd(node.Text);
}
}
}
I think until I figure out a lot of these underlying things in the code, I
will never understand what
I am looking at. I can't see individual properties being saved, its just a
mystery.
Rob
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:uI******** *****@TK2MSFTNG P04.phx.gbl...
Rob,
If you are talking about something you can persist, then you need to
look at other options. You need to associate that identifier with the
node.