Well just design your pop-up form (Form2 say) in the normal way and display it from the main form with this code:
// add this private field private Form2 f2 = null;
// within a button click handler, say private void button1_Click(object sender, EventArgs e) { if (f2 == null) { f2 = new Form2(); f2.FormClosed += Form2_FormClosed; } f2.ShowDialog(); }
// add this handler to main form manually, not from designer private void Form2_FormClosed(object sender, FormClosedEventArgs e) { // get text from textbox1 on Form2 TextBox tb = (TextBox)f2.Controls["textBox1"]; // display it in a label on main form, say label1.Text = tb.Text; }
1 answers
Well just design your pop-up form (Form2 say) in the normal way and display it from the main form with this code:
answered one year ago by:
17279
301
thanks vulpes..at the beginning I used the formclosed from the designer and i wondered how to move it to the source code of form1.cs :)