Link to home
Start Free TrialLog in
Avatar of AmitBAcharya
AmitBAcharyaFlag for India

asked on

STOP CLOSING PARENT MDI FORM

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...
Avatar of t_itanium
t_itanium
Flag of United Arab Emirates image

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
ASKER CERTIFIED SOLUTION
Avatar of arif_eqbal
arif_eqbal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AmitBAcharya

ASKER

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.
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...
Avatar of arif_eqbal
arif_eqbal

How are you showing the child form ?
Can you post the code