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

enumerating eventhandlers

P: n/a
Does any body know how to get a list of event handlers
assigned to a paticular event?

I'd like to be able to determine if a sub has already been
added as an event handler for a form.paint event.

while eventinfo has methods for addhandler and remove
handler I don't se a way to do a 'gethandler'
or 'enumeratehandlers' etc.

I'm trying to aviod adding a handler more than once.

Thanks
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
EventHandlerList

=)

-CJ
"Phil" <pb***@1sourceautowarranty.com> wrote in message
news:1c****************************@phx.gbl...
Does any body know how to get a list of event handlers
assigned to a paticular event?

I'd like to be able to determine if a sub has already been
added as an event handler for a form.paint event.

while eventinfo has methods for addhandler and remove
handler I don't se a way to do a 'gethandler'
or 'enumeratehandlers' etc.

I'm trying to aviod adding a handler more than once.

Thanks

Nov 20 '05 #2

P: n/a
So, are you suggesting keeping my own list of what
handlers I assign?

if so, riddle me this batman...
do you know a way to check if and event has any handler
assigned at all, even if it was done outside the scope of
whats doing the checking?
i.e. if form.paint is nothing then .....etc
-----Original Message-----
EventHandlerList

=)

-CJ
"Phil" <pb***@1sourceautowarranty.com> wrote in message
news:1c****************************@phx.gbl...
Does any body know how to get a list of event handlers
assigned to a paticular event?

I'd like to be able to determine if a sub has already been added as an event handler for a form.paint event.

while eventinfo has methods for addhandler and remove
handler I don't se a way to do a 'gethandler'
or 'enumeratehandlers' etc.

I'm trying to aviod adding a handler more than once.

Thanks

.

Nov 20 '05 #3

P: n/a
Phil,
Remember that events are defined in terms of Delegates. Delegates have a
GetInvocationList method to get the list of handlers attached to that
delegate, which will be the list of handlers attached to the event.

When you define an event in your class VB.NET will define a delegate field
for that event. You can use this field to get the invocation list.

Public Class Phil

' this creates a NotifyEvent field in the class.
Public Event Notify As EventHandler

Public Sub CheckNotify()
Dim list() As [Delegate] = NotifyEvent.GetInvocationList()
For Each handler As [Delegate] In list
' do something interesting here.
Next
End Sub

End Class

Hope this helps
Jay
"Phil" <pb***@1sourceautowarranty.com> wrote in message
news:1c****************************@phx.gbl...
Does any body know how to get a list of event handlers
assigned to a paticular event?

I'd like to be able to determine if a sub has already been
added as an event handler for a form.paint event.

while eventinfo has methods for addhandler and remove
handler I don't se a way to do a 'gethandler'
or 'enumeratehandlers' etc.

I'm trying to aviod adding a handler more than once.

Thanks

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.