silly newbie question - application with more than one form

  • Thread starter Christian Stüben
  • Start date
C

Christian Stüben

Hi all,
please forgive my silly newbie question. Using visual studio .net 2003,
i want do do some application that uses more than one winform, both in
c++ and c#.

Creating the second, third, and so on form with the designer is no
problem.

But how can i check if form2, form3 etc. are already initialised, and
how can i make them visible?

Assigning something like "Form2.Activeform.visible = true;", or
"Activate ();" or "Show ();" give me no result, the second form always
stays invisible.

Thanks to all that can help.

Chris
 
W

Wajih-ur-Rehman

Dear Chris,

First of all you would have to instantiate your form and then you call the
show method. It will definitely show you the form. For example, lets say
that you have a form named Form1 then you will do the following

Form1 f = new Form1();
f.Show();

Hope this will help

Best Regards
Wajih-ur-Rehman
 
C

Chris Hornberger

Designate one of your forms as the main focal point of your
application. Give that form class-level variables that refer to all
your other forms. Create a mechansim to show the forms for you as a
method of your main form. Expose that form publicly.

Something like...

public enum AppForms(
Download,
Updoad,
Edit
}

public void ShowForm( AppForms appForm ){
switch( appForm ){
case AppForms.Download:
if( frmDown == null ){
frmDown = new FrmDownload();
}
frmDown.Show();
...
...
}

Something like that would work. You can also research how to create
each of your form classes as singletons.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top