How to unload all open forms

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2006
Posts: 6
Reputation: hari12341 is an unknown quantity at this point 
Solved Threads: 0
hari12341 hari12341 is offline Offline
Newbie Poster

How to unload all open forms

 
0
  #1
Oct 1st, 2006
Hi All,
I need some guidance here...How does one close or unload all open forms in VB.Net. Can someone please help me out in this regard?
Thanks very much.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 90
Reputation: Inanna is on a distinguished road 
Solved Threads: 6
Inanna's Avatar
Inanna Inanna is offline Offline
Junior Poster in Training

Re: How to unload all open forms

 
0
  #2
Oct 1st, 2006
Application.Exit()
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 6
Reputation: hari12341 is an unknown quantity at this point 
Solved Threads: 0
hari12341 hari12341 is offline Offline
Newbie Poster

Re: How to unload all open forms

 
0
  #3
Oct 2nd, 2006
i may try that out but this is the warning issued in msdn under application.exit() method

CAUTION The Form.Closed and Form.Closing events are not raised when the Application.Exit method is called to exit your application. If you have validation code in either of these events that must be executed, you should call the Form.Close method for each open form individually before calling the Exit method.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 6
Reputation: hari12341 is an unknown quantity at this point 
Solved Threads: 0
hari12341 hari12341 is offline Offline
Newbie Poster

Re: How to unload all open forms

 
0
  #4
Oct 2nd, 2006
I used a for in vb to close all open forms but i am new to .Net and have not been able to do the same in .Net
Code in VB:

  1. for each frm in forms
  1. frm.close()
  1. next

In .Net this does not work i guess...
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: How to unload all open forms

 
0
  #5
Oct 2nd, 2006
hmn:
  1. for each XFrm in forms
  2. unload XFrm
  3. next XFrm
?
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 90
Reputation: Inanna is on a distinguished road 
Solved Threads: 6
Inanna's Avatar
Inanna Inanna is offline Offline
Junior Poster in Training

Re: How to unload all open forms

 
0
  #6
Oct 3rd, 2006
CAUTION The Form.Closed and Form.Closing events are not raised when the Application.Exit method is called to exit your application. If you have validation code in either of these events that must be executed, you should call the Form.Close method for each open form individually before calling the Exit method.
If you're using .NET 2.0 then that's not the case anymore. Application.Exit() raises the Form.Closing events.
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: How to unload all open forms

 
1
  #7
Oct 4th, 2006
This is for VB Express 2005:
  1. For i As Integer = My.Application.OpenForms.Count - 1 To 0 Step -1
  2. If My.Application.OpenForms.Item(i) IsNot Me Then
  3. My.Application.OpenForms.Item(i).Close()
  4. End If
  5. Next i
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1
Reputation: syeedsan is an unknown quantity at this point 
Solved Threads: 0
syeedsan syeedsan is offline Offline
Newbie Poster

Re: How to unload all open forms

 
0
  #8
Feb 29th, 2008
Originally Posted by Inanna View Post
If you're using .NET 2.0 then that's not the case anymore. Application.Exit() raises the Form.Closing events.

Application.Exit() causes all the dialogs to get closed. but, It creates some problems in my test applicatin. is there anyother way to close all the opened forms by the current Application..??
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: How to unload all open forms

 
0
  #9
Feb 29th, 2008
end
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 300
Reputation: jireh is an unknown quantity at this point 
Solved Threads: 42
jireh's Avatar
jireh jireh is offline Offline
Posting Whiz

Re: How to unload all open forms

 
0
  #10
Sep 23rd, 2009
Well I've try also the code below:
  1. Dim openForm As Form = Nothing
  2.  
  3. For index As Integer = My.Application.OpenForms.Count - 1 To 0 Step -1
  4. openForm = My.Application.OpenForms.Item(index)
  5. If openForm IsNot Me AndAlso Not TypeOf openForm Is DevExpress.Utils.Win.TopFormBase Then
  6. openForm.Close()
  7. openForm.Dispose()
  8. openForm = Nothing
  9. End If
  10. Next

but there were some forms that were not close or rather I say was not detected as openforms.

My question is when during opening the form and it encounters some errors but still able to load the form, does the form considered as not an openform?
Last edited by jireh; Sep 23rd, 2009 at 3:03 am.
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC