Managing Multiple Windows Forms

G

Guest

I have a VB.NET application that has a number of windows forms. What I would like to do is be able to move from form to form and close the calling form once the new form is open. For example - Form1 has a comand button that creates Form2 as a new Form2 and shows Form2. Once Form2 has been displayed I want to close Form1. My problem is that since Form2 is created within the scope of Form1, when I close Form1, Form2 goes out of scope and additionally closes. I want Form2 to stay open. An example of code is as follwes. In the click envent of Button1 on Form
Dim Form2 as New Form2
From2.sho
Me.clos

I would then like to Have Form2, create and open Form3 and then close. Form3 maythen need to open Form4 and close or may open Form1 and close.

I was ablt to do this without problem in VB6 but becasue of scope it is not working in Vb.Ne

Thank You - Pau
 
P

Patrick Steele [MVP]

I have a VB.NET application that has a number of windows forms. What I would like to do is be able to move from form to form and close the calling form once the new form is open. For example - Form1 has a comand button that creates Form2 as a new Form2 and shows Form2. Once Form2 has been displayed I want to close Form1. My problem is that since Form2 is created within the scope of Form1, when I close Form1, Form2 goes out of scope and additionally closes. I want Form2
to stay open. An example of code is as follwes. In the click envent of Button1 on Form1
Dim Form2 as New Form2
From2.show
Me.close

I would then like to Have Form2, create and open Form3 and then close. Form3 maythen need to open Form4 and close or may open Form1 and close.

I was ablt to do this without problem in VB6 but becasue of scope it is not working in Vb.Net

Use the ApplicationContext class. See:

http://tinyurl.com/39zf4
 

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