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.

Re: OnClosing event doesn't close form by Alex

Alex
Tue Jul 12 14:36:21 CDT 2005

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.

"C# Dev" <ng@vertextek.com> wrote in message
news:uDwpXSxhFHA.3300@TK2MSFTNGP15.phx.gbl...
> 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.
>
>
>
>



Re: OnClosing event doesn't close form by Lloyd

Lloyd
Tue Jul 12 21:50:11 CDT 2005

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

> button or some other programmatic method.