Using multiple windows forms

M

Mario

Hi,

I am trying to create an application with multiple windows forms. The
problem that I have is that after creating the window forms, I do not
know how to open formN after closing Main form. Each form is in its
own class. What I want to do is the following:

1. Click a button on Main menu.
2. Close main menu ( I would use hide if possible)
3. Open form2
4. Open other forms and hide or close the previous form.
5. Eventually able to go back to Main form.

I have been experimenting with creating new forms from Main form and
closing/disposing them. However, I would like to learn how to use
forms that I can create using the windows forms that I have created.
Any help is appreciated. Thanks.

Mario
 
F

FUnky

I don't think you've explained your problem clearly.
If you know how to create new forms from main form, you could very well do
the same from other forms too.
 
M

Mario

Hi Funky,

Below are the things that I have done.

1. Created a Windows C# project.
2. Added windows forms to the project.(Mainform, form1, form2, form3)
3. Added buttons and text boxes to the respective forms.

What I want to do now is to click a button on Mainform to bring up
form1, then click a button on form1 to birng up form2....Each form is
in its own class. The reason why I want to do it this way is because I
have a number of methods associated with each form and it is easier for
me to create the forms by using the toolbox.

I have had success in doing the following:

1. From Mainform, create form1.
2. Hide MainForm, and create form2 from form1....

All these forms are creatd dynamically...what I want to do is to call
forms that have already been designed using VS graphical inteface.
Hope this helps explaining what I want to do and thanks..

Mario
 
C

Chris Dunaway

Your problem is still not clear. Once you have designed the forms, are
you not able to instantiate them?

Form1 form1 = new Form1();
from1.Show();

Does code like this not work for you? What errors/problems are you
getting? Perhaps if you were to show us some of the code you tried, we
might be able to see something that would help.
 
P

Pradeep

hey,
if you are using visual basic..then the following would help

inside the button click event write

me.hide()
form2.show()

the same could be written in all forms and then in the last form u can
write
me.hide()
form1.show() which ll bring u back to the main form....

thats it..
bye
Pradeep
 

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