5281
asked on
Show/Hide Form
Hi,
I have two forms, Form1 and Form2. Form 1 is the main form, From 2 takes an argument and Form 2 has lots of information. I want two forms are loaded together when application starts but Form2 is hided, when user click a button, Form2 will show. How to do that?
public Form2(Form1 ownerForm)
{
....
}
I have two forms, Form1 and Form2. Form 1 is the main form, From 2 takes an argument and Form 2 has lots of information. I want two forms are loaded together when application starts but Form2 is hided, when user click a button, Form2 will show. How to do that?
public Form2(Form1 ownerForm)
{
....
}
In the Form1 Load, you need to add code to show Form2:
Form2 frm2 = new Form2();
frm2.Show();
Form2 frm2 = new Form2();
frm2.Show();
ASKER
zverjuga:
My Form2 has a treeview and a recursive function, it takes about 1 minute to load the Form2 on my PDA (it is a little bit long and this is samrt device application). Therefore, I want to load the two forms together at first and hide Form2, when we need it, click a button to show it. It save some time to wait for Form2 to load.
digital:
Where should I put the following code? I put this code in the public Form1(), and then try to show Form2 from Button1_Click, but it doesn't recognize the frm2 there.
public Form1()
{
Form2 frm2 = new Form2(this);
frm2.Hide();
}
public void Button1_Click(object sender, EventArgs e)
{
frm2.show(); <---- It doesn't recoganize frm2 here.
}
My Form2 has a treeview and a recursive function, it takes about 1 minute to load the Form2 on my PDA (it is a little bit long and this is samrt device application). Therefore, I want to load the two forms together at first and hide Form2, when we need it, click a button to show it. It save some time to wait for Form2 to load.
digital:
Where should I put the following code? I put this code in the public Form1(), and then try to show Form2 from Button1_Click, but it doesn't recognize the frm2 there.
public Form1()
{
Form2 frm2 = new Form2(this);
frm2.Hide();
}
public void Button1_Click(object sender, EventArgs e)
{
frm2.show(); <---- It doesn't recoganize frm2 here.
}
what about the opacity property
form.Opacity =
set from 0 to 100
form.Opacity =
set from 0 to 100
ASKER
p_davis:
I am not quite understand what you are saying, I don't have a Opacity property, I need code.
I am not quite understand what you are saying, I don't have a Opacity property, I need code.
Hi,
I would not recommend populating the whole the tree view at once, especially for PDA screen as you cannot see it all anyway.
I would have initial tree view with all nodes except root collapsed, then populate a tree node as user opens it.
Also I noticed that form object creation takes most time for my forms (not the Show() method), so if this is the case for you then you can create Form object during system Idle time and call Show once object is done.
I would not recommend populating the whole the tree view at once, especially for PDA screen as you cannot see it all anyway.
I would have initial tree view with all nodes except root collapsed, then populate a tree node as user opens it.
Also I noticed that form object creation takes most time for my forms (not the Show() method), so if this is the case for you then you can create Form object during system Idle time and call Show once object is done.
is this form a System.Windows.Forms.Form?
Form Form2 = new Form();
Form2.Opacity
Form Form2 = new Form();
Form2.Opacity
ASKER
P_davis: This is a smart device application.
sorry about that
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Not sure what are you fighting with...
You can just delay second form creation till the button click
Open in new window