Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / December 2003

Tip: Looking for answers? Try searching our database.

Closing Form1 When Moving To Form2

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Si Tran - 30 Dec 2003 00:26 GMT
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?
Robert Gruen [MSFT] - 30 Dec 2003 16:16 GMT
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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.