|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
e.Cancel = True in MDI Child Closing eventIn the Closing event of many of the forms, I have code that asks the user whether he is sure he wants to close the form, because it contains unsaved data. If the user clicks "No" then the code sets e.Cancel = True, which cancels the closure. This works just great. But when the user closes the MDI parent form, the cancellation seems to be completely ignored. The MessageBox appears, I click "No", but the form (and the application) closes anyway. In VB6, aborting the closing in a form's QueryUnload event would cancel the closure of the application in this circumstance. I'm eager to try to obtain this behaviour in VB.NET as I'm worried about people losing work that they have entered into these forms. Is there any way to achieve this? Many thanks, -- (O) e n o n e The expected behaviour is that if you attempt to close an MDI parent then
the Closing event of each MDI child will fire. If any one of these child forms sets e.Cancel = True then no further Closing events will be fired, and the MDI parent will not close. I have this scenario and it works as described. Can you confirm that with one MDI parent and one Child, clicking the MDI Parent close button does not fire the child closing event? Charles Show quoteHide quote "Oenone" <oen***@nowhere.com> wrote in message news:CO01e.987$7J2.564@newsfe2-win.ntli.net... > I'm writing an application with various MDI child forms. > > In the Closing event of many of the forms, I have code that asks the user > whether he is sure he wants to close the form, because it contains unsaved > data. If the user clicks "No" then the code sets e.Cancel = True, which > cancels the closure. This works just great. > > But when the user closes the MDI parent form, the cancellation seems to be > completely ignored. The MessageBox appears, I click "No", but the form > (and > the application) closes anyway. > > In VB6, aborting the closing in a form's QueryUnload event would cancel > the > closure of the application in this circumstance. I'm eager to try to > obtain > this behaviour in VB.NET as I'm worried about people losing work that they > have entered into these forms. > > Is there any way to achieve this? > > Many thanks, > > -- > > (O) e n o n e > > Charles Law wrote:
> The expected behaviour is that if you attempt to close an MDI parent Hmm, I just set up a project to test this and it worked exactly as you> then the Closing event of each MDI child will fire. If any one of > these child forms sets e.Cancel = True then no further Closing events > will be fired, and the MDI parent will not close. I have this > scenario and it works as described. described. There must be something else going on in my real application -- I'll investigate. Thanks for your help, -- (O) e n o n e Oenone wrote:
> There must be something else going on in my real application -- I'll In the Closing event of the MDI Container form, I had some code which closed > investigate. the entire application down. This was a hang-over from the VB6 implementation and was unsurprisingly causing the behaviour I described. With this removed it's all working perfectly. Thanks again, -- (O)enone
Loopy over loops
looking for CPU-specific developer's benchmarking How to Prevent Flicker when Updating ListView From VB.NET to Delphi7 convert. Form that slides up into view (MSN Style) AddHandler RemoveHandler Question date problem in datagrid List View question Print the content of a listview Listview with black box as cursor |
|||||||||||||||||||||||