473,320 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

enumerating eventhandlers

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
3 3591
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Brett Mostert | last post by:
Hi, I need to be able to Enumerate through Printer Drivers, ports, printers and so fourth. And even add printers, ports, and drivers and setup printers. Sofar i can do all of the following...
2
by: Bishman | last post by:
Can anyone suggest a method of enumerating instances of MSDE 2000 without using DMO ? Using C++, MFC, and ADO. Thanks
3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
4
by: Lyn | last post by:
Hi, This question may seem a bit academic... To learn more about Access VBA, I have been enumerating the properties of various form controls. This was mostly successful and I have learned a lot...
1
by: Kevin | last post by:
Hi, How can I enumerate a linked list while being hable to delete any number of elements while enumerating ? I was using: struct st { ... struct st *prev;
3
by: Robert | last post by:
I need some assistance doing some "right way to do it" coding. The following are EventHandlers associated with Delegates in a child form that call a procedure in the MDI form that resets a timer....
1
by: Timo | last post by:
I haven't tried coding eventhandlers in Global.asax yet -- any "gotchas" I should be aware of? Do programming errors there require bouncing IIS? Will handlers in Global.asax be able to access...
2
by: Tony | last post by:
I have this problem - I have a hashtable, containing a list of filenames. Every 60 seconds, I have a thread that enumerates thru this hashtable, and based on some simple logic, some of the items...
3
by: Armin | last post by:
Hello I have a UserControl with a Click Event. Is it possible to find out the List of all Delegates/Eventhandlers using the Event. I read something about a "getinvocationlist" Methode for...
1
by: Kasper Birch Olsen | last post by:
Hi NG Im adding a bunch of linkbuttons to a page, in a for loop, but I cant get the eventhandlers to work. A simplyfied version of the code looks like this: for (int i = 0; i<10; i++) {...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.