Click here to Skip to main content
16,006,065 members
Home / Discussions / C#
   

C#

 
GeneralMoving a file from one server to another Pin
chubbysilk2-Dec-03 4:12
chubbysilk2-Dec-03 4:12 
GeneralRe: Moving a file from one server to another Pin
Heath Stewart2-Dec-03 4:32
protectorHeath Stewart2-Dec-03 4:32 
GeneralGDI - Creating Images Pin
MrEyes2-Dec-03 3:31
MrEyes2-Dec-03 3:31 
GeneralRe: GDI - Creating Images Pin
Heath Stewart2-Dec-03 4:05
protectorHeath Stewart2-Dec-03 4:05 
GeneralRe: GDI - Creating Images Pin
MrEyes2-Dec-03 7:25
MrEyes2-Dec-03 7:25 
Generalneed source code Pin
Member 5581242-Dec-03 3:09
Member 5581242-Dec-03 3:09 
GeneralRe: need source code Pin
Christian Graus2-Dec-03 10:37
protectorChristian Graus2-Dec-03 10:37 
QuestionSaving nodes in a TreeView to an XML file? Pin
thomasa2-Dec-03 2:53
thomasa2-Dec-03 2:53 
I'm struggeling a bit here.
I'm trying to save a TreeView and all of it's nodes as shown in the code belowe:

xw.WriteStartElement("TreeView");
foreach(TreeNode tn in theTreeView.Nodes)
{
xw.WriteStartElement("TreeNode");
xw.WriteAttributeString("Text", tn.Text);
if(theNode.Parent == null)
{
xw.WriteAttributeString("Parent", "null");
foreach(TreeNode n in tn.Nodes)
{
xw.WriteStartElement("TreeNode");
xw.WriteAttributeString("Text", n.Text);
xw.WriteAttributeString("Parent", n.Parent.ToString());
xw.WriteEndElement();
}
}
xw.WriteEndElement();
}
xw.WriteEndElement();

The xml file looks something like this:
<treeview>
- <treenode text="Startnode" parent="null">
<treenode text="Node0" parent="TreeNode: Startnode">
<treenode text="Node3" parent="TreeNode: Startnode">
<treenode text="Node4" parent="TreeNode: Startnode">

- <treenode text="Node5" parent="null">
<treenode text="Node6" parent="TreeNode: Node5">


The problem is that I only get the first nodes and the second nodes in the TreeView hirarki. If I continue to add a foreach(TreeNode n in theNode.Nodes) I will end up writing it forever...

Is there a better way of getting all the nodes in the TreeView than
foreach(TreeNode n in tn.Nodes)?

or what must I do?



Thanks in advance for your help Rose | [Rose] ,
Thomas
AnswerRe: Saving nodes in a TreeView to an XML file? Pin
Heath Stewart2-Dec-03 4:00
protectorHeath Stewart2-Dec-03 4:00 
GeneralXML Comments Pin
Colin Angus Mackay2-Dec-03 0:39
Colin Angus Mackay2-Dec-03 0:39 
GeneralRe: XML Comments Pin
Heath Stewart2-Dec-03 3:41
protectorHeath Stewart2-Dec-03 3:41 
GeneralDate / Time Pickers Pin
MrEyes1-Dec-03 23:49
MrEyes1-Dec-03 23:49 
GeneralRe: Date / Time Pickers Pin
Heath Stewart2-Dec-03 3:40
protectorHeath Stewart2-Dec-03 3:40 
GeneralRe: Date / Time Pickers Pin
MrEyes2-Dec-03 3:51
MrEyes2-Dec-03 3:51 
QuestionConverting a string to System.Drawing.Color? Pin
thomasa1-Dec-03 21:53
thomasa1-Dec-03 21:53 
AnswerRe: Converting a string to System.Drawing.Color? Pin
Rocky Moore1-Dec-03 23:40
Rocky Moore1-Dec-03 23:40 
AnswerRe: Converting a string to System.Drawing.Color? Pin
je_gonzalez2-Dec-03 11:52
je_gonzalez2-Dec-03 11:52 
GeneralLocalizable Pin
CillyMe1-Dec-03 19:13
CillyMe1-Dec-03 19:13 
GeneralRe: Localizable Pin
Heath Stewart2-Dec-03 3:34
protectorHeath Stewart2-Dec-03 3:34 
GeneralRe: Localizable Pin
CillyMe2-Dec-03 4:17
CillyMe2-Dec-03 4:17 
GeneralRe: Localizable Pin
Heath Stewart2-Dec-03 4:26
protectorHeath Stewart2-Dec-03 4:26 
GeneralRe: Localizable Pin
CillyMe2-Dec-03 15:53
CillyMe2-Dec-03 15:53 
QuestionHow can i create vedio file from collection of images in C# Pin
KRathor1-Dec-03 18:43
KRathor1-Dec-03 18:43 
AnswerRe: How can i create vedio file from collection of images in C# Pin
Heath Stewart1-Dec-03 18:59
protectorHeath Stewart1-Dec-03 18:59 
GeneralRe: How can i create vedio file from collection of images in C# Pin
KRathor1-Dec-03 19:10
KRathor1-Dec-03 19:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.