Braintique.com header
Left Navigation Bar

Losing Your Forms

Let’s say we want to use the button on the Form2 instance to get back to our instance of Form1. Here’s where we start to run into the limitations of instantiating a new instance of a form class. To fully illustrate the point, add the symmetric code to the click event of the button on the Form2 instance to show an instance of Form1:

private void btnForm1_Click(object sender, System.EventArgs e) {
Form1 form1 = new Form1();
form1.Show();
}

Next, fire up the project. Enter some interesting phrase in the textbox in Form1, such as I think therefore I exist! Click the button to load it into the label. Now click the button to show the instance of Form2. On Form2, click the button to show an instance of Form1. No matter how many times you do this, all you’ll get is a new instance of Form1, meaning the text that was loaded into the label by the user will not be displayed.

Form1

Often times, of course, there will be a lot more information—input by the user or gathered in some other way—in a Windows form instance than a single phrase. So, how can we get back to the instance of Form1 that we want to return to with its information intact?

There has to be an easy way to resolve this common (and very frustrating) programming problem. For the solution, read on.

Previous Table of Contents Next


Google
 
Web www.braintique.com
www.digitalfieldguide.com www.googleplexblog.com


Home | Barticles | Blogs | Books | Services | FAQ | Contact

© Braintique.com. All rights reserved.

Search Engine Optimization







RSS 2.0 Syndication feed

Syndication Viewer

Our Web host:
IX WebHosting



Food for Your Brain! Get a Barticle! Questions Answered Books for You What We Can Do For You Contact Us Brain Food Questions Answered Books for You What We Can Do For You Frequently Asked Questions About Us Google Research Photoshop Wi-Fi and Wireless Networking The Natural Way to Write