|
-
February 17th, 2006, 01:03 PM
#1
Maintain data between Forms
Hi
I have one main Form1 which contains a button that call ShowDialog () to show a new Form2. In this new Form2 I have a Label, a Textbox and a Button. I write something in Textbox and that is copied in the Label after I push the Button. When I close the Form2 and reopen it, the text in Label has been lost (of course). The more simple solution is to store the text in a static string and Load it in Label when Form2 loads.
Is this the best way to maintain data between forms, by using static fields?
If I have more complex Controls like a TreeView I must save and store all the data in static variables?
Is there any other way to handle it? (it would be great if a .NET class can handle this automatically)
Thanks!!!!!!!!!!!
-
February 19th, 2006, 08:11 AM
#2
Re: Maintain data between Forms
 Originally Posted by ccfriend
Is this the best way to maintain data between forms, by using static fields?
Not sure if it's the best, but it is a reasonably good way.
-
February 19th, 2006, 07:30 PM
#3
Re: Maintain data between Forms
.NET classes can "handle this automatically" and you already do it all the time. You have no doubt set properties and passed paraneters to methods, including constructors. That's all you have to do to get data into an object. I strongly suggest that you read this three part tutorial: http://www.devcity.net/Articles/94/1/multipleforms.aspx
-
February 20th, 2006, 12:13 AM
#4
Re: Maintain data between Forms
Hai,
Maintain ur lable info into a local variable and send to form1 on closing using as an argument of a function.
Again when opening Form2 Send through an overloaded constructor.
Kolluru
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|