Solved

STOP CLOSING PARENT MDI FORM

Posted on 2006-06-27
6
300 Views
Last Modified: 2008-02-01
Hi,

I have a winforms based MDI application.
When a user clicks on the close button on the Main MDI, amongst many open child forms, one of forms has a prompt for closure like

"Do you want to close this form?, OK / CANCEL"

Is it possible to stop the closing of the main MDI depending on the user's choice of closing the child form?

As of now, the application continues back to the main MDI execution and closes the main MDI, regardless of whether the user has clicked OK or CANCEL

If yes, would appreciate some sample code...
0
Comment
Question by:AmitBAcharya
  • 2
  • 2
6 Comments
 
LVL 5

Expert Comment

by:t_itanium
ID: 16998852
in the closing event of the mdi form:  to get the closing event select the mdi form and select the closing event the code will appear...

then you have to show a messagebox with yesno buttons..

dim x as integer
x=MessageBox.Show("are you sure?","Confirm","sd",System.Windows.Forms.MessageBoxButtons.YesNo,System.Windows.Forms.MessageBoxIcon.Exclamation);

if x=6 then

else

e.cancel=true

end if
0
 
LVL 19

Accepted Solution

by:
arif_eqbal earned 500 total points
ID: 16998965
Well the MDI should not close at all
What version are you using ?
in VS2005 if one of the child forms cancels the close it is propogated and the parent does not close as well
check if you have set
    childForm.Parent = MDIForm

0
 

Author Comment

by:AmitBAcharya
ID: 16999271
I am not able to do that directly with the application architecture, as the parent form and child forms are in separate MS.NET solutions and referred in a complex hierarchy.

Is there a way to stop all processing upon clicking cancel while closing a child form. The control should not go back to the parent form.
0
 
LVL 5

Expert Comment

by:t_itanium
ID: 16999365
can you clarify your canse more. please... it is abit unclear and need details... as far as i understand to prevent the form from closing e.cancel=true will do so...and checking for the NO respond of messagebox it returns 7 as integer...
0
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 16999366
How are you showing the child form ?
Can you post the code

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now