Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

STOP CLOSING PARENT MDI FORM

Posted on 2006-06-27
6
Medium Priority
?
308 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
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 …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 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