Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

STOP CLOSING PARENT MDI FORM

Posted on 2006-06-27
6
Medium Priority
?
309 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
5 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 1500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Integration Management Part 2
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

782 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