473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Form Closing VB.NET VS2005

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


Mar 2 '07 #1
3 5914

Zim,

You could do Me.Close before Me.Dispose.

Kerry Moorman
"Zim Babwe" wrote:
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


Mar 2 '07 #2
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
"Kerry Moorman" <Ke**********@discussions.microsoft.comwrote in message
news:97**********************************@microsof t.com...
>
Zim,

You could do Me.Close before Me.Dispose.

Kerry Moorman
"Zim Babwe" wrote:
>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



Mar 2 '07 #3
No. After all of the references to Form1 are released, it is set for
garbage collection.

Robin S.
===========================
"Zim Babwe"
<zi******@ifyouthinkiamgoingtoputmyrealemailaddres shereyouarecrazy.com>
wrote in message news:Og**************@TK2MSFTNGP03.phx.gbl...
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
"Kerry Moorman" <Ke**********@discussions.microsoft.comwrote in message
news:97**********************************@microsof t.com...
>>
Zim,

You could do Me.Close before Me.Dispose.

Kerry Moorman
"Zim Babwe" wrote:
>>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




Mar 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: RAJ | last post by:
hi plz tell me how to know "how window is going to close"... i have to right code for X button of forms... plz telll me thanks bye
1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
1
by: **Developer** | last post by:
When I get a closing event in a MID Child form I don't know if the child form is closing or the main form is closing. Is there a way to tell? Thank
3
by: Bob | last post by:
I haver a user login form (winforms app using vs2005 in VB.NET). After succesfull validayion of user I want to open a first form and close the loging form that was used, If I write If...
4
by: Matt | last post by:
Another interesting issue: I set the default font on most of my forms to what I want the text in my controls to show up as (say, Verdana 9pt.), and then just change the font on labels and buttons...
2
by: dchman | last post by:
I have a C# app in VS2005. the form has a datetime picker with valuechanged event. When the form closes, the valuechanged event is fired and an error is thrown in its code when it tries to get a...
7
by: Bob | last post by:
I have a winforms app written in Vs2005 Vb.Net, The setiings are to Enable the application Framework and I defined a splashform. Works fine if no errors occur. I do a checking on the mainform load...
11
by: joey.powell | last post by:
Hello, I have a windows forms application (VS2005) where I need to do the following... 1. Startup with a main form. 2. Have the user to select a file and then bring up a second form modally...
13
by: Edwin Smith | last post by:
I have a form which displays a DataGridView table generated with the VS2005 tools. The database is a Pervasive v.9 with an ODBC driver. The DataGridView works great except when I'm done and I...
6
by: Doc John | last post by:
Assuming I have several child Forms open (not maximized) in my MDI Form, when I maximize any of them and then close it, all my other Forms automatically maximize. How come? Is there an easy...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.