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

Can't find an Event Handler

P: n/a
What I'm trying to do is find a way to determine at run time if a particular
event handler in a UserControl has been defined. Here's a snippet of code:

Public Event Button_Click As EventHandler

Public WriteOnly Property ButtonClick() As System.EventHandler

Set(ByVal Value As System.EventHandler)

If Not Value Is Nothing Then

AddHandler Me.Button_Click, Value

Me.HasButtonClick = True

End If

Console.WriteLine("Handler exists=" & Not (Me.Events(Me.Button_ClickEvent)
Is Nothing))

End Set

The write statement prints out False, but the handler is in fact installed,
i.e., the event is handled by the event handler passed in is executed. Why
doesn't the Events list show the handler?

Ken
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
* "Ken Kast" <ke*@NOSPAMkenkast.com> scripsit:
What I'm trying to do is find a way to determine at run time if a particular
event handler in a UserControl has been defined. Here's a snippet of code:


<http://groups.google.com/groups?selm=%23AelgzK%23CHA.3208%40TK2MSFTNGP11.ph x.gbl>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

P: n/a
I saw the Google posting and actually tried it first. I exception off
because GetInvocationList is Nothing (which I assume is equivalent to my not
finding the handler in Events). So I'm looking to solve one or the other of
the puzzles.

Ken

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uZ**************@TK2MSFTNGP12.phx.gbl...
* "Ken Kast" <ke*@NOSPAMkenkast.com> scripsit:
What I'm trying to do is find a way to determine at run time if a particular event handler in a UserControl has been defined. Here's a snippet of
code:
<http://groups.google.com/groups?selm...K2MSFTNGP11.ph
x.gbl>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.