I just started on VB.NET and I'm encountering a problem.
I instantiate form2 within form1, so I can switch over to
Form2. I used this code in form1 under a click event
handler:
Dim z As Form2
z = New Form2()
z.Show()
Problem: How do I go about closing form1 when I move over
to form2?
Si,
What you can do is create a public property in Form2 that holds a reference
to form1. What you could then do is call z.Show() then say Me.Hide() and
then later show Form1 again invoking the property of form2 that has the
reference to form1. If you actually want to destroy Form1 and then show
form2 and still have your application run (since closing the main form
closes your application), you'll want to use the application context class.
ApplicationContextClas -
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwindowsformsapplicationcontextclasstopic.asp
Sample -
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/
html/reaworapps1.asp
Thanks! Robert Gruen
Microsoft, VB.NET
This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "Si Tran" <sitran75@yahoo.com>
[quoted text clipped - 28 lines]
| Problem: How do I go about closing form1 when I move over
| to form2?