Creating Events similar to Form.Closing

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

Hi there,

I was just curious if anyone knew how to create a .Net event that is
similar to Form.Closing event, where in I can set the Cancel property of the
event argument to true and it will cancel the processing of the event.

Any sugessition will be appreciated.

Thanks
 
Hi News,

The question's a bit vague at the moment.

What would be triggering the event? What would the event handler do and
what would it not do if it were cancelled?

For example, you can raise an event in any class and have a Cancel field
in a custom EventArgs. Anyone hooked into your event can set this so that when
it returns to your class you can take or avoid certain actions.

Is this what you have in mind? Is there something more specific? Would you
just like to know more about how events work?

Regards,
Fergus
 
make one of the event args boolean and pass it byref...raise the event
passing a local variable...do what you need to based on the value of your
local variable after raising the event.

public event aboutToDoSomthing(byref goAheadAndDoIt as boolean)

private sub prepareToDoSomething()
dim doIt as booleand
raiseevent aboutToDoSomething(doIt)
if not doIt then return
' guess they really wanna do it
end sub

hth,

steve


| Hi there,
|
| I was just curious if anyone knew how to create a .Net event that is
| similar to Form.Closing event, where in I can set the Cancel property of
the
| event argument to true and it will cancel the processing of the event.
|
| Any sugessition will be appreciated.
|
| Thanks
|
|
 
* "news.microsoft.com said:
I was just curious if anyone knew how to create a .Net event that is
similar to Form.Closing event, where in I can set the Cancel property of the
event argument to true and it will cancel the processing of the event.

Any sugessition will be appreciated.

Written from scratch:

\\\
Public Class Bla
Public Event MyEvent(ByVal sender As Object, ByVal e As MyEventArgs)
 
Hi,

Did you have any concern on this issue, please post here?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top