Advertisement

03.05.2008 at 03:38PM PST, ID: 23217981
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Closing multiple forms

Tags: VB.Net
Hi, would someone be able to supply me with the code for this... If one form is closed to also close another form. Any help would be great, thanks
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: Cannibal_Jack
Solution Provided By: Idle_Mind
Participating Experts: 2
Solution Grade: A
Views: 9
Translate:
Loading Advertisement...
03.05.2008 at 03:51PM PST, ID: 21055992

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.05.2008 at 03:56PM PST, ID: 21056024

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.05.2008 at 04:02PM PST, ID: 21056067

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.05.2008 at 04:16PM PST, ID: 21056154

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.05.2008 at 04:19PM PST, ID: 21056178

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.05.2008 at 04:28PM PST, ID: 21056232

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.05.2008 at 04:36PM PST, ID: 21056273

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.05.2008 at 04:54PM PST, ID: 21056362

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.05.2008 at 05:48PM PST, ID: 21056592

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.06.2008 at 07:34AM PST, ID: 21061144

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.06.2008 at 07:39AM PST, ID: 21061240

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.06.2008 at 09:09AM PST, ID: 21062418

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.06.2008 at 09:53AM PST, ID: 21062921

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.06.2008 at 10:00AM PST, ID: 21062988

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.06.2008 at 10:45AM PST, ID: 21063369

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
03.06.2008 at 01:21PM PST, ID: 21064904

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • Automotive
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Displays / Monitors
  • Handhelds / PDAs
  • Components
  • Peripherals
  • Laptops/Notebooks
  • Servers
  • Misc
  • Apple
  • Embedded Hardware
  • Networking Hardware
  • Storage
  • Desktops
  • New Users
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMware
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Virtualization
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • Web Computing
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Consulting
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMware
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Automation
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Web Services
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Web Computing
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Lounge
  • Business Travel
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
  • Automotive
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
03.05.2008 at 03:51PM PST, ID: 21055992

Rank: Sage

You can do thin on close event:

My.Application.OpenForms.Item("YourFormName").Close()
 
03.05.2008 at 03:56PM PST, ID: 21056024
This might sound stupis but how do I enter that into the form close event?
 
03.05.2008 at 04:02PM PST, ID: 21056067

Rank: Sage

You can do this on the form that you want to close the other:

Private Sub frm_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        My.Application.OpenForms.Item("YourFormNameToClose").Close()
    End Sub
 
03.05.2008 at 04:16PM PST, ID: 21056154
Hi I'm getting this error...
An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll

on this line...
My.Application.OpenForms.Item("Form2").Close()
 
03.05.2008 at 04:19PM PST, ID: 21056178

Rank: Sage

Then from of the name is "Form2" ?
 
03.05.2008 at 04:28PM PST, ID: 21056232
The form I put the code in is form1 and when form 1 is closed I want form2 to close also.
 
03.05.2008 at 04:36PM PST, ID: 21056273
I dont know if this helps but form2 is actually the mdi parent and form one is the child.
 
03.05.2008 at 04:54PM PST, ID: 21056362

Rank: Sage

Try this:

    Private Sub Form2_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        For Each frm As Form In Me.MdiParent.MdiChildren
            If frm.Name = "Form3" Then
                frm.Close()
            End If
        Next
    End Sub

Attention: This event will fire also when you close the MDI form.
 
03.05.2008 at 05:48PM PST, ID: 21056592

Rank: Genius

When you create your MdiChild (Form1), use AddHandler() to wire up its FormClosed() event.  Completely Dispose() of it though before you close the MdiParent:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Public Class Form2
 
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frm1 As New Form1
        frm1.MdiParent = Me
        AddHandler frm1.FormClosed, AddressOf frm_FormClosed
        frm1.Show()
    End Sub
 
    Private Sub frm_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs)
        Dim frm As Form = DirectCast(sender, Form)
        frm.Dispose()
        frm = Nothing
 
        Me.Close()
    End Sub
 
End Class
Open in New Window
 
03.06.2008 at 07:34AM PST, ID: 21061144
I have tried both solutions and neither seem to work,I think maybe I'm getting a little muddled up here.
Ive started a new project now I have a form called MDI_Container_Form and a form Called Test_Form. Test_Form Is a child to MDI_Container_Form and when the program is run Test_Form opens up instantly inside MDI_Container_Form. What I' like to do is when the red cross next to minimize and maximize is press on Test_Form that it also closes the MDI_Container_Form.
 
03.06.2008 at 07:39AM PST, ID: 21061240

Rank: Genius

I'm 100% certain my code works in VB.Net 2005...here it is again with your form names:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Public Class MDI_Container_Form
 
    Private Sub MDI_Container_Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim tf As New Test_Form
        tf.MdiParent = Me
        AddHandler tf.FormClosed, AddressOf frm_FormClosed
        tf.Show()
    End Sub
 
    Private Sub frm_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs)
        Dim frm As Form = DirectCast(sender, Form)
        frm.Dispose()
        frm = Nothing
 
        Me.Close()
    End Sub
 
End Class
Open in New Window
Accepted Solution
 
03.06.2008 at 09:09AM PST, ID: 21062418

Rank: Sage

>> Test_Form opens up instantly inside MDI_Container_Form
But that is not what you asked in the beginning. You want to close the project wuen Test_Form closes =

You just need to do this:

Private Sub Test_Form_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
     Application.Exit()
End Sub
Assisted Solution
 
03.06.2008 at 09:53AM PST, ID: 21062921

Rank: Genius

What is the purpose of the MDI container if you want the whole app to close when the child is closed?

Wouldn't a single form suit this task better?  I don't think you are giving the big picture...     ?

Application.Exit() will certainly close both forms...but what if there are other forms you want to stay open?
 
03.06.2008 at 10:00AM PST, ID: 21062988

Rank: Sage

>> Application.Exit() will certainly close both forms...but what if there are other forms you want to stay open?

Idle_Mind,

From is last post I understand that he have only two forms and want to close the application. Maybe I'm worng!!!
 
03.06.2008 at 10:45AM PST, ID: 21063369

Rank: Genius

You're exactly right jpaulino...that is what he has DESCRIBED.

I'm just wondering what the point is!  Why bother with an MDI approach at all?  Killing the whole app seems like using a nuclear bomb to kill a fly.  Just wondering if we aren't getting the "bigger picture" here....
 
03.06.2008 at 01:21PM PST, ID: 21064904
Thanks, I've sorted it with the code from above. The reason I wanted to do it this way was because the child form was a login window and if the login window was closed there would be no point in the container window being open. thanks for all your help guys.
 
 
03.06.2008 at 05:15PM PST, ID: 21066381
 
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628