473,409 Members | 2,056 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,409 software developers and data experts.

closing MDI Application with a button

hi,

im developing a mdi application and want to close this application and all its child forms using a button but im not sure how to do it. Please note that this button is NOT in parent form but in one of the child form. here is my sample code. is it correct way to do it??

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
  2.         Dim frm As New frmMain 'this is the parent form
  3.         For Each temp As Form In frm.MdiChildren
  4.             temp.Dispose()
  5.         Next
  6.         Application.Exit()
  7. End Sub 
im using .NET 1.1 and VS 2003
Nov 16 '07 #1
7 1296
Plater
7,872 Expert 4TB
Can you get away with doing:
Expand|Select|Wrap|Line Numbers
  1. Me.Parent.Close
  2.  
???
Nov 16 '07 #2
yes i can but i dont think it will close all other child forms. what u say???
Nov 17 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
If you close the parent form (which is MDI type), the child forms attached to it will close too.
If you want to exit the application
Application.Exit does the trick, however you will need to find the equivalent of it in vb .net
Nov 17 '07 #4
Application.Exit actually works in vb.net

so i guess its just Application.Exit and all other child forms will be closed automatically (both hidden and not-hidden) ???
Nov 18 '07 #5
Shashi Sadasivan
1,435 Expert 1GB
Application.Exit actually works in vb.net

so i guess its just Application.Exit and all other child forms will be closed automatically (both hidden and not-hidden) ???
Yes, Application.Exit will shut down the entire application thread. (and its children)
Nov 18 '07 #6
thanks for all the replys
Nov 19 '07 #7
hi
you use following code
Form[] charr= this.MdiChildren;

//For each child form set the window state to Maximized
foreach (Form chform in charr)
chform.Dispose();
Nov 19 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michel | last post by:
Yes, there is a way of forbidding a form being closed if you create a boolean variable (blnCanClose = False) in the form's Unload event. I didn't read all the responses, but I have just such a form...
5
by: nick_faye | last post by:
Hi, I am still a newbie to VB and using MS Access 2000. I am currently trying to provide a preview of reports before printing them. My program is simple: AC.DoCmd.OpenReport "MyReport",...
2
by: chris in grimsby | last post by:
MDIChild Window Closing event not raised when MDI Parent is in a class library! Intructions to recreate problem: 1. Create a ClassLibrary project 2. Add an MDIParent form and a form that will...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: Charles Law | last post by:
Under what circumstances would e.Cancel be set to True on entry to the Closing event of an MDI child form? I have found that this is why my application won't close properly. I can explicitly set...
10
by: Ricky W. Hunt | last post by:
I have written a close routine to handle an "Exit" button to close the application properly. How do I make sure this gets executed if the user closes it another way (by pressing the "X" in the...
3
by: Oenone | last post by:
I'm writing an application with various MDI child forms. In the Closing event of many of the forms, I have code that asks the user whether he is sure he wants to close the form, because it...
14
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought...
1
by: Kakkanattu | last post by:
Hi, I am developing an application in .NET 3.0. When i tried to right click the application from task bar and click on Close, the application is closing inconsistently. Also I put a promt at close...
11
by: Simon van Beek | last post by:
Dear reader, By opening an application I get always the main Access window with the closing cross in the above right corner. Is there a possibility to make this closing cross invisible? ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.