fattumsdad
asked on
Multiple Forms
I have 2 forms. Form1 and Form2. When the program starts, I want Form1 to be displayed. When a button is pressed, I want Form1 to disappear and Form2 to be visible. What is the button_click code to make this happen? I am used to VB... Form1.Visible = false, Form2.Visible = true etc :)
Thanks,
Tony
Thanks,
Tony
Are you going to use Form1 again? Or if you do, will it be a 'new' Form1?
try form1.hide=true;
Since your application is probably using,
Application.Run(new Form1());
The most simple code is:
Hide();
new Form2().Show();
Application.Run(new Form1());
The most simple code is:
Hide();
new Form2().Show();
ASKER
eternal,
I'll be switching between both forms. I am using Application.Run(new MainForm()); The second form I'm using is frmAdmin... I tried Hide(); frmAdmin().Show() to no avail :( Also tried MainForm.hide = true...
I'll be switching between both forms. I am using Application.Run(new MainForm()); The second form I'm using is frmAdmin... I tried Hide(); frmAdmin().Show() to no avail :( Also tried MainForm.hide = true...
ASKER
I added:
this.visible = false;
And that will hide Form1... now I just have to get Form2 open LOL
this.visible = false;
And that will hide Form1... now I just have to get Form2 open LOL
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, I meant to explicitly declare,
public frmAdmin AdminForm
private void SwitchToAdminForm()
MainForm mainForm;
public void SwitchToMain()
all as Private, so if you want to change them they should look like:
private frmAdmin AdminForm
private void SwitchToAdminForm()
private MainForm mainForm;
private void SwitchToMain()
(Just like to keep the code consistent, will not affect operation - you can always make them public/internal later if you have a need).
public frmAdmin AdminForm
private void SwitchToAdminForm()
MainForm mainForm;
public void SwitchToMain()
all as Private, so if you want to change them they should look like:
private frmAdmin AdminForm
private void SwitchToAdminForm()
private MainForm mainForm;
private void SwitchToMain()
(Just like to keep the code consistent, will not affect operation - you can always make them public/internal later if you have a need).
ASKER
Right on! Thanks a lot (again)!