Form Closing VB.NET VS2005

  • Thread starter Thread starter Zim Babwe
  • Start date Start date
Z

Zim Babwe

I have a Windows Application and I want to load another form when the user
clicks a menu item.

I am currently in Form1

When I click on the menu, the code is

Form2.Show
Me.Dispose


------


In Form1 I have the following two routines, but they never get called. I
put a breakpoint on the IF statements, but they never get there. Form2
shows up. How can I make sure that I can call my SaveRegions routine when
leaving?

Thanks for any help


-----------------------------

Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) _
Handles Me.FormClosed

If g_SubRegionsModified Then
Call SaveRegions()
g_SubRegionsModified = False
End If

End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) _
Handles Me.FormClosing

If g_SubRegionsModified Then
Call SaveRegions()
g_SubRegionsModified = False
End If

End Sub
 
Thanks for the suggestion. I tried that and it worked. The next question
is I changed the code to the following, calling the close before the show.
I thought if the close executed, then there could be no more code called,
but it seemed to work. Does that mean after calling Form2.Show, Form1 is
still in memory?



Me.Close
Form2.Show
 
No. After all of the references to Form1 are released, it is set for
garbage collection.

Robin S.
===========================
"Zim Babwe"
 
Back
Top