Switching between forms in C# calls Form_load

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Im trynig to switch back and forth between 2 forms using form.show() and form.hide() but it keeps calling Form_load for some reason.

this is the code:

<b>From Form1:</b>

private void btnModify_Click(object sender, EventArgs e)
        {
            modifyForm mod = new modifyForm();
            mod.Show();
            this.Hide();
        }//end btnModify_Click

<b>From modifyForm:</b>

private void btnCancel_Click(object sender, EventArgs e)
        {
            Form1 toMain=new Form1();
           
            this.Close();
            toMain.Show();
        }

I have a feeling its because of <i>Form1 toMain=new Form1();.  It seems to open a whole new form1 and as a result calls form1_load.  How can I get around this? I just want to go back to the form i hid.
</i>


View the full article
 
Back
Top