Mike see code using reflections I put up... It does just this.
On 2/14/07, Mike Andrews <[EMAIL PROTECTED]> wrote:
Yep, can't agree more.
For this case it's just for testing and debugging.
I'm not interested in the Add/Remove handlers for the Event either. I just
want the Delegate instances wh
Yep, can't agree more.
For this case it's just for testing and debugging.
I'm not interested in the Add/Remove handlers for the Event either. I just
want the Delegate instances which belong to the CheckBox.CheckedChangedevent.
Since an instanced Delegate has a GetInvocationList() method, this i
For VB.NET (which the OP seemed to be in), I haven't found an easy
analog to C#'s "something == null" syntax.
In VB.NET 2005, you can do a Custom Event and have your own AddHandler
routine, which gets stored in a delegate that you can then check...but
otherwise, I don't think it can be done witho
Be advised:
(1) That only works when the calling assembly(ies) have sufficient CAS
permissions that allows reflection against non-public members; and
(2) The class in question actually (a) does not provide a custom add/remove
handler and (b) is implemented using a language like C# that creates a
As per Phil's post, a Delegate instance has a GetInvocationList() method
that returns an array of Delegates, one for each list. This is assuming you
have a delegate instance.
I've had other times when I would have like to know if there listeners for a
particular event.
My original problem point
> and the compiler tells me:
> The event 'System.Web.UI.WebControls.CheckBox.CheckedChanged' can only
> appear on the left hand side of += or -=
>
> What might I be doing incorrectly here?
> Is what I want to do even possible?
What are you trying to accomplish functionally? You can't really do wh
On 2/14/07, Mike Andrews <[EMAIL PROTECTED]> wrote:
...and the compiler tells me:
The event 'System.Web.UI.WebControls.CheckBox.CheckedChanged' can only
appear on the left hand side of += or -=
The problem is that the event name is *not* a delegate. The event is
*backed* by a delegate, but t
Here is a version that works from outside of the class ...
static void PrintListenners(object o, string _EventName)
{
Type t = o.GetType();
FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
BindingFlags.Instance);
foreach (FieldInfo f in fie
You would assign this AddHandler delegate to CheckChanged event in you
Initialize method
- Tanweer
-Original Message-
From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf
Of Mike Andrews
Sent: Wednesday, February 14, 2007 2:52 PM
To: ADVANCED-DOTNET@DISCUSS.DEVE
The event is seen differently from outside the class .. try this. I
think you can only do this for classes that you have control over.
public class Test
{
public event EventHandler Something;
public void DoSomething()
{
if (Something != null)
{
Thank you
After some investigation, I cannot seem to get this to work.
I created this method:
private static void DisplayDelegate(Delegate obj) {
foreach (Delegate d in obj.GetInvocationList()) {
Console.WriteLine("Method Name: {0}", d.Method);
Console.WriteLine(
google for GetInvocationList
that should point you in the right direction
-Original Message-
From: Discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] Behalf Of Mike Andrews
Sent: Wednesday, February 14, 2007 2:52 PM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: [ADVANCED-DOT
Guys,
Do any of you know if it's possible to determine if an event for an object
has been assigned a delegate?
Example:
Dim cb As New CheckBox()
cb.Name = "MyCheckBox"
AddHandler(cb.CheckChanged, AddressOf CheckChanged)
...
Public Sub CheckChanged(Object sender, EventArgs e)
...
End Sub
Is i
13 matches
Mail list logo