Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Parameters Between Two Forms

Status
Not open for further replies.

sjf905

Programmer
Sep 20, 2006
13
US
Hello, I have one main form with a text box that needs to be filled by a parameter from a second form (which opens on a button click in form1). Right now I have something that looks like this:

//in form1
private void button1_Click(Object sender, EventArgs e) {
form2 f2 = new form2();
f2.Show();
//looks like I need some kind of system pause here...I tried a system pause and a Console.ReadLine, to no avail
textBox1.Text = f2.param.ToString();
}

The problem is that f2.param fills the textBox right away, before it can be retrieved from the user on form2. If its not obvious, I'm a little new to C#.
Thanks for the help.
 
Hi,

The Show method shows the other form and continues processing the method. In case of using Show you should use ShowDialog. This forces the application to wait until form2 is closed again.

Greetz,

Geert


Geert Verhoeven
Consultant @ Ausy Belgium

My Personal Blog
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top