How would i make use of tags property of a node so that i can get the attributes of an xml node. I have to display an xml tree in a winform and then when i click on any node, its attributes should get displayed on a list box in same window. I want to make use of tags property, but for that i need to convert that tree node in the winform into an xml node. I wanted to store the tree node in the tag and then typecast that tag to an xml node. I dont know how to do it? I am a newbie at C# so there might be some discrpancy in language...please help
views:
54answers:
1
A:
When adding the TreeNode class, your code would look like this:
// Create the node.
TreeNode newNode = new TreeNode();
// Configure.
...
// Set the tag property to hold the XML element.
XmlElement currentElement = ...;
newNode.Tag = currentElement;
// Add to the tree view.
...
Then when you have the tree view node, you would get the element like this:
TreeNode currentNode = ...;
// Get the XmlElement.
XmlElement currentElement = (XmlElement) currentNode.Tag;
// Process the element.
...
casperOne
2009-03-02 19:34:25
can u please fill up your blanks? and also to fetch the attributes i use the event handler treeview_AfterSelect, so second part of your code would be written there?
2009-03-02 20:16:49