I've got an MDI form with child forms that I'd like to refactor to a single form with a tab control containing child controls, in order to move away from MDI clunkiness.
When looking at converting the child forms into child controls (or usercontrols), I do see that I'd lose the FormClosing
event, which some of the child forms use.
I can override Dispose
to handle some of the functionality, but in some cases I'd like to cancel the closing event. Also, I'd like this event to be called before the control is closed even when the form it's on isn't closing, so wiring the control to the form's closing event isn't an option.
Is there a clean way of reproducing the FormClosing
event in the control class, or should I keep the child forms as Forms when I add them to the tab control?
Edit: To be a little more clear, I'm looking for a way to raise something like ControlClosing
on a user control before it's closed (not necessarily when the host form is closed) in order to prompt the user if they wish to save changes to their data, and allow the user to select the standard Yes / No / Cancel.
I'm not looking to override the closing of the form that hosts the control.