How to check assignment of Event Handler

Hi All,

I have following line in my C# code :

bkmkRow.Selected+=new WordTools.SelectionEventHandler(this.STTable_Row_BookmarkSelected);

where bkmkRow is the Bookmark object of Word class (in VSTO).

Now before assignment of "SelectionEventHandler" to "Selected" event, how can I check that any event handler has been assigned or not?

Any help?

Thanks in advance.......

[704 byte] By [VikramChudasama] at [2007-12-24]
# 1

if(bkmkRow.Selected == null)

Cheers ;)

RizwanSharp at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# Language...
# 2
Oh sorry to say, but I tried that thing also and it throws an error "Selected must be left side of +=".

So I can not check it with NULL.

VikramChudasama at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# Language...
# 3
i think you can only check from within the bkmkrow class
joeycalisay at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# Language...
# 4

joeycalisay wrote:
i think you can only check from within the bkmkrow class

Yes That is obvious but I think there is also a way to check form the other side. YOu can also use your own logic to attain this.

Think again ;-)

RizwanSharp at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# Language...
# 5
There doesn't appear to be an normal way to check if an EventHandler has events assigned to it.
CharlieCalvertMSFT at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# Language...
# 6
Charlie Calvert MSFT wrote:
There doesn't appear to be an normal way to check if an EventHandler has events assigned to it.
i think the poster is referring to the inverse, checking if any eventhandler/listener is attached to a particular event
joeycalisay at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# Language...
# 7

Joey,

You might well be right. But either way I come at this problem, I don't think there is a clean solution. It is kind of an interesting problem though, if you think you have a solution that would be cool.

My main goal here, however, was just to try to close out a thread that looked like it would never get a good answer. That's always a dangerous proposition, but I thought it might be worth a try in this case.

- Charlie

CharlieCalvertMSFT at 2007-10-8 > top of Msdn Tech,Visual C#,Visual C# Language...