Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello all,

 

I am using event handlers in a class I am writing and I want to add my own event hanldling if the control does not already have it. As an example, let's say I want to handle SelectedIndexChanged for a ComboBox if it is not currently trapping that event. How do I go about determining if a given ComboBox is already trapping SelectedIndexChanged? Thanks in advance for any ideas and/or suggestions!

Posted

I believe you can test to see if an event is hooked up using the following code.

if(comboBox1.SelectedIndexChanged==null){}

Anybody looking for a graduate programmer (Midlands, England)?
  • Leaders
Posted
VB event handling is a little different. In C#, events and delegates are treated exactly the same, where as VB has special syntax for events and hides the actual backing multicast delegate from the programmer. The VB RaiseEvent keyword automatically performs a check for null before invoking the delegate (in C# this must be done explicitly), but provides no mechanism to see if the event is wired as far as I know.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...