ADO DOT NET Posted July 1, 2007 Posted July 1, 2007 In FormClosing event of my 1st form, I show the 2nd form like this: Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Dim F As New Form2 F.ShowDialog() End Sub But the problem is that Form1 waits for Form2 to be closed and then it closes! How should I let's Form1 to completely unload and then load the Form2? Thanks :) Quote
Administrators PlausiblyDamp Posted July 2, 2007 Administrators Posted July 2, 2007 ShowDialog will suspend execution of the Form1' Closing event until the second form is closed, have you tried just using F.Show() instead. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Leaders snarfblam Posted July 4, 2007 Leaders Posted July 4, 2007 I'm guessing that Form1 might be the application's main form. If this is the case, then F.Show() won't work. (Hence the ShowDialog?) If I'm right then there is a right way to approach the situation, and "the other way." What you should probably do is write a custom Main() for your program. How this is done might vary from version to version with VB (I haven't used newer versions). You would also need to inherit the ApplicationContext class and write your own custom ApplicationContext that manages your forms for you. The "other way" is to simply hide your Form1 before showing Form2, but this prevents resources from being released in a timely fasion and is not the preferred technique. Quote [sIGPIC]e[/sIGPIC]
Eduardo Lorenzo Posted July 5, 2007 Posted July 5, 2007 Have you explored the MDI option? Most issues I have encountered that needs one form to open a second form is when there are just too many controls to display on one form. MDI (Multiple Document Interface) or maybe Tabs are options that can be considered. my 2 cents. Quote
Leaders dynamic_sysop Posted July 7, 2007 Leaders Posted July 7, 2007 i put an example in the codebank over 2 years ago of being able to close the main form that loads without shutting the app down, the vbcode looks a bit screwed up because of messed up colour tags, but here's the link a readable code is found on an external link to vbforums here a very basic source example is included. regards. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.