Closing child form conumdrum...

A

Anthony Hughes

I've got the following scenario

ParentForm spawns ChildForm on which the user can edit data.

ChildForm_Closing gives the user a Save & Close / Discard & Close / Cancel
(don't close) choice

ParentForm_Closing calls ChildForm.Close to invoke ChildForm_Closing when the
main app is shut down.

However, if the user selects Cancel, I need the main app to not close. Since
ChildForm.Close returns no status as to whether it closed or not, what should
I be checking to know whether to cancel ParentForm_Closing?

Many thanks in advance!
Ant
 
C

Chris Dunaway

You could add a boolean property to your child form called OkToClose.
Then in the Parent's closing event you check that value and cancel the
close:

ChildForm.Close
If Not ChildForm.OkToClose Then
e.Cancel = True
End If

There may be other ways, this one should give you some ideas.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top