Beezgetz

Hi,

I have treeView1 populated with parents nodes, each parent having exactly three (3) childs (children). Each child can have saved a lot of grandchilds.

+Customer1

-Customer2

+FirstCalculator

+SecondCalculator

+ThirdCalculator

-Customer3

-FirstCalculator

Data1

Data2

-SecondCalculator

Data3

Data4

-ThirdCalculator

Data5

Data6

Data7

+Customer4

I created three (3) application (those are children), sort of calculators, each calculating result from given input data. I would like to save:

a/ class populated with inputed data,

b/ some ArrayList and

c/ some text (log),

under child node as a single grandchild node in treeView1 of Form1.

I would not save results, since they will appear after selecting grandchild node from treeView1, in manner that:

-appropriate calculator-application (Form2, or Form3, or Form4) will appear and

-will load saved class, ArrayList and text

-from selected grandchild node, and calculate results.

This sounds complicated to me, but it is basic save/load...

Thanx!



Re: Windows Forms General Save in treeView1, Load from treeView1

Figo Fei - MSFT

Hi, Beezgetz

Honestly I don't quite understand what exactly you want to do.

Could you just give a senario or a case to follow Which point is hard for you to do, function implimentation issue or logical designing issue

It seems that you want to show other forms in one form, right You can try to create an instance of the specific form and use Show() or ShowDialog() method of it.

Thanks






Re: Windows Forms General Save in treeView1, Load from treeView1

Beezgetz

Hi Figo,

I have 3 "calculators" that should be (3) nodes under one node (customer). As I click on one of the calculator node, it should open a new form (calculator) and be ready to work [so far I've done that with show()].

As I finish calculating, I want to save inputed data and results of that calculation as a new node(result1) under that calculators node. So I can choose to open that result node (under calculator node) in manner, that calculator would open and load earlyer inputed data and results (from result node).
-Customer1
+CalculatorFirst
-CalculatorSecond
*Result1
*Result2
+CalculatorThird
+Customer2

So far i've been told I should work with xml serialization in order to save/load data & results, but i've just started . All my data are some strings, a lot of double-s and one texRichBox(serving as a Capitan's log).
I am a bigginer, so I would appriciate example with one string, a double and richTextBox, and how to put them into xml from a form, into treeView and back...

I am sorry for my english, I'll be glad to give some more info!!

Thanks a lot, Beezgetz




Re: Windows Forms General Save in treeView1, Load from treeView1

Figo Fei - MSFT

Hi,

Actually, in such a case, you don't need to generate xml file. Just plain text file (*.txt) can do.

Well, I know you are beginner, so the example follows:

To save text in a file example(use StreamWriter):

Code Snippet

using (StreamWriter sw = new StreamWriter(@"D:\Results.txt"))
{
sw.WriteLine("whatever you want it to be");
}

In this way, you can save the result.

To get the results into tree view example:

Code Snippet
using (StreamReader sr = new StreamReader(@"D:\Results.txt"))
{
treeView1.Nodes.Add(sr.ReadLine());
}

These example can do the function, and more you must do the logical work yourself, since that is your design. Smile

Good luck!






Re: Windows Forms General Save in treeView1, Load from treeView1

Beezgetz

HaHA HA HA HA
Figo, you score!

I'm thrilled! It seems to do the trick!
I'll work on it for a while, and I'll come back to forum when I get to another obstacle.

Thanx!




Re: Windows Forms General Save in treeView1, Load from treeView1

Beezgetz

Hi Figo,
and how do I get to add lines to Result.txt
what I mean is, if I already saved result, and I need to put a new line

using (StreamWriter sw = new StreamWriter(@"D:\Results.txt"))
{
sw.WriteNewLine(textBox1.Text); //
}


Thanx!




Re: Windows Forms General Save in treeView1, Load from treeView1

Figo Fei - MSFT

Code Snippet
using (StreamWriter sw = File.AppendText(@"D:\Results.txt"))
{
sw.WriteLine("newline");
}

Thanks




Re: Windows Forms General Save in treeView1, Load from treeView1

Beezgetz

Man, you just did something that I needed for a long time.

Thank you million times!

Best Regards, Beezgetz