Yet another question for you guys:
I have created 2 forms in my application. I want a button on Form1 to "call open" Form2 without opening another window. AKA: Sort of like a "Next Page" option.
What code would I put in the button event handler to perform that task? |
| Landon Parks Monday, December 25, 2006 10:32 AM |
Merry Christmas!
You open the other like this:
public void SomeMethod()
{
Form2secondForm= new Form2();
// Hide() will kept the form in memory, Close() will close the Form1
Form1.Hide() or Form1.Close();
secondForm.Show();
} |
| bthumber Monday, December 25, 2006 11:49 AM |
Hi,
In other way, you also can use multiple panels in one form. |
| Figo Fei Tuesday, December 26, 2006 2:33 AM |
Panels really are your best option like Figo Mei stated, since it's the
only way to make it look like you're in the same form (because you
really are). The code supplied by bthumber has bad news written all over it  If you do { Form2 frm2= new Form2(); frm1.Close(); frm2.Show(); } This will throw an exception because you created an object (frm2) inside an object (frm1) that you closed... Maybe I'm wrong, but I do think it will happen this way. |
| Blackened.pt Tuesday, December 26, 2006 1:00 PM |
Merry Christmas!
You open the other like this:
public void SomeMethod()
{
Form2secondForm= new Form2();
// Hide() will kept the form in memory, Close() will close the Form1
Form1.Hide() or Form1.Close();
secondForm.Show();
} |
| bthumber Monday, December 25, 2006 11:49 AM |
I figured it out, thanks.
By the way, here is the way I larned to do it:
Form1.ActiveForm.Hide();
Form2 theSecondForm = new Form2();
theSecondForm.ShowDialog();
|
| Landon Parks Monday, December 25, 2006 1:17 PM |
Hi,
In other way, you also can use multiple panels in one form. |
| Figo Fei Tuesday, December 26, 2006 2:33 AM |
Panels really are your best option like Figo Mei stated, since it's the
only way to make it look like you're in the same form (because you
really are). The code supplied by bthumber has bad news written all over it  If you do { Form2 frm2= new Form2(); frm1.Close(); frm2.Show(); } This will throw an exception because you created an object (frm2) inside an object (frm1) that you closed... Maybe I'm wrong, but I do think it will happen this way. |
| Blackened.pt Tuesday, December 26, 2006 1:00 PM |
It works when I tested it. When I open Form 2, it hides Form 1 as well.
I was not really looking for a code to actually bring a new form up INSIDE of another form... Although that would be neat if I could find out how to do that... Give me the details, what code do i put where? lol...
(im completly new to this, forgive my ignorance).
Thanks a billion trillion! |
| Landon Parks Wednesday, December 27, 2006 12:15 AM |
So, does anyone know how to bring up Form 2, Form 3, etc inside of another form, via the use of frames? |
| Landon Parks Wednesday, December 27, 2006 8:53 PM |
Hi, Landon
To let more people see and discuss the problem, I suggest you to separate it into a new thread, in which way you may get more satisfactory answers.
Thank you |
| Figo Fei Thursday, December 28, 2006 2:13 AM |