OnClosing event doesn't close form

C

C# Dev

Hi Group,

I raise OnClosing event in a handler of a menu item. It invokes the
OnClosing registered delegate but it doesnot close the form.
But if i click on the close icon [X] of the form it invokes the OnClosing
registered delegate and then closes the form. Can anyone
help why same event handler (OnClosing) have different behaviour when
invoked from code or clicked on from close button [X].
// Following is the menu event handler raising OnClosing event.

private void miExit_Click(object sender, System.EventArgs e)

{base.OnClosing(new CancelEventArgs(false)); }



Thanks.
 
A

Alex Passos

You should call the form's Close method. It will setup the necessary
messages for the window to shut down and then call the OnClosing event.
OnClosing is called by the framework as the form is closing from the X
button or some other programmatic method.
 
L

Lloyd Dupont

Almost!
let's see....
You should call the form's Close method. It will setup the necessary right!

messages for the window to shut down and then call the OnClosing event.
OnClosing is called by the framework as the form is closing from the X
wrong! no need to call OnClosing again!, it's already done by the call to
close
 

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