By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,884 Members | 1,333 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,884 IT Pros & Developers. It's quick & easy.

What is the event to trap when user clicks X to close form?

P: n/a
On my form if the user clicks the upper right hand corner to close the form
I want to trap that event and do a check to see if closing is allowed, if
not, I want to stop the form closing action.

Can anyone tell me how I can do this?

Thanks for any help
Bob
Oct 21 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Form_Close event is fired when u try to close form.

On Sat, 21 Oct 2006 16:59:07 +0100, Robert Dufour <bd*****@sgiims.com>
wrote:
On my form if the user clicks the upper right hand corner to close the
form
I want to trap that event and do a check to see if closing is allowed, if
not, I want to stop the form closing action.

Can anyone tell me how I can do this?

Thanks for any help
Bob



--
Tiago Salgado // http://weblogs.pontonetpt.com/tiagosalgado
Oct 21 '06 #2

P: n/a
Don't forget the Form.Closing Event. Which is fired before the disposal.

--
Thiele Enterprises - The Power Is In Your Hands Now!

--
"Tiago Salgado" <ti********************@gmail.comwrote in message
news:op.thsfgaqtdysvon@tiagosalgado...
Form_Close event is fired when u try to close form.

On Sat, 21 Oct 2006 16:59:07 +0100, Robert Dufour <bd*****@sgiims.com>
wrote:
On my form if the user clicks the upper right hand corner to close the
form
I want to trap that event and do a check to see if closing is allowed, if
not, I want to stop the form closing action.

Can anyone tell me how I can do this?

Thanks for any help
Bob



--
Tiago Salgado // http://weblogs.pontonetpt.com/tiagosalgado
Oct 21 '06 #3

P: n/a
"Robert Dufour" <bd*****@sgiims.comschrieb:
On my form if the user clicks the upper right hand corner to close the
form I want to trap that event and do a check to see if closing is
allowed, if not, I want to stop the form closing action.
In addition to the other replies:

If you are using .NET 2.0, check out the form's 'FormClosing' event too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Oct 21 '06 #4

P: n/a
There is also the option to override the WndProc method if you really
needed to.

Thanks,

Seth Rowe
Herfried K. Wagner [MVP] wrote:
"Robert Dufour" <bd*****@sgiims.comschrieb:
On my form if the user clicks the upper right hand corner to close the
form I want to trap that event and do a check to see if closing is
allowed, if not, I want to stop the form closing action.

In addition to the other replies:

If you are using .NET 2.0, check out the form's 'FormClosing' event too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Oct 22 '06 #5

P: n/a
On Sat, 21 Oct 2006 11:59:07 -0400, "Robert Dufour" <bd*****@sgiims.comwrote:
>On my form if the user clicks the upper right hand corner to close the form
I want to trap that event and do a check to see if closing is allowed, if
not, I want to stop the form closing action.

Can anyone tell me how I can do this?

Thanks for any help
Bob
In VB6, there was the QueryUnload event which had an UnloadMode argument, one of
which was vbFormControlMenu which was specific to the "X" button and the control
menu, "Close".

In .Net, AFAIK, there is no functional equivalent short of using the WndProc method.
FormClosing event will fire when the "X" button is pressed (3-User Closing), but it
also fires for the same reason if Me.Close() is called - 3-User Closing.

Gene
Oct 22 '06 #6

P: n/a
Thank you all

"gene kelley" <ok**@by.mewrote in message
news:tc********************************@4ax.com...
On Sat, 21 Oct 2006 11:59:07 -0400, "Robert Dufour" <bd*****@sgiims.com>
wrote:
>>On my form if the user clicks the upper right hand corner to close the
form
I want to trap that event and do a check to see if closing is allowed, if
not, I want to stop the form closing action.

Can anyone tell me how I can do this?

Thanks for any help
Bob

In VB6, there was the QueryUnload event which had an UnloadMode argument,
one of
which was vbFormControlMenu which was specific to the "X" button and the
control
menu, "Close".

In .Net, AFAIK, there is no functional equivalent short of using the
WndProc method.
FormClosing event will fire when the "X" button is pressed (3-User
Closing), but it
also fires for the same reason if Me.Close() is called - 3-User Closing.

Gene

Oct 22 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.