Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serializing TreeNode

Status
Not open for further replies.

Ramo83

Programmer
Apr 7, 2005
20
IE
Hello,
I want to serialize the object TreeNode, but it always throw this exeption:
{"There was an error reflecting property 'ContextMenu'."} - this is the inne
r exeption.
I'm using the XMLSerializer to serialize the treeNode into a XML file.
How can this problem be solved?
 
Just write a recursive function to output the XML?

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
Can you please make it clearer?
Thanks alot
 
Code:
XmlDocument xml = new XmlDocument();
xml.LoadXml(createXml(myTreeView.Nodes));
private string createXml(TreeNodeCollection treeNodes)
{
  string xml = "";
  foreach(TreeNode tnode in treeNodes)
  {
    xml += "<" + tnode.Text + ">" + createXml(tnode.Nodes) + "</" + tnode.Text + ">";
  }
  return xml;
}

Jon

"There are 10 types of people in the world... those who understand binary and those who don't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top