Solved

Show/Hide Form

Posted on 2007-11-26
10
237 Views
Last Modified: 2013-12-16
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)
{
....
}
0
Comment
Question by:5281
  • 3
  • 3
  • 2
  • +1
10 Comments
 

Expert Comment

by:zverjuga
ID: 20352775
Hi,
Not sure what are you fighting with...
You can just delay second form creation till the button click
from1button_Click()
{
  if(this.form2 == null)
    this.form2 = new Form2(this);
 
  this.form2.Show(this);
}

Open in new window

0
 
LVL 8

Expert Comment

by:digital_thoughts
ID: 20352822
In the Form1 Load, you need to add code to show Form2:

Form2 frm2 = new Form2();
frm2.Show();
0
 

Author Comment

by:5281
ID: 20352962
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.
}


0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 22

Expert Comment

by:p_davis
ID: 20353028
what about the opacity property

form.Opacity =

set from 0 to 100
0
 

Author Comment

by:5281
ID: 20353252
p_davis:

I am not quite understand what you are saying, I don't have a Opacity property,  I need code.
0
 

Expert Comment

by:zverjuga
ID: 20353368
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.
0
 
LVL 22

Expert Comment

by:p_davis
ID: 20353417
is this form a System.Windows.Forms.Form?

Form Form2 = new Form();

Form2.Opacity
0
 

Author Comment

by:5281
ID: 20353488
P_davis:  This is a smart device application.
0
 
LVL 22

Expert Comment

by:p_davis
ID: 20353516
sorry about that
0
 
LVL 8

Accepted Solution

by:
digital_thoughts earned 250 total points
ID: 20353963
You would need to make frm2 a variable for the class to be able to access it in both the page load and the button click.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question