Closing child form conumdrum...

  • Thread starter Thread starter Anthony Hughes
  • Start date Start date
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
 
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
 
Back
Top