Psst! Did you know DevelopmentNow is a mobile web site design agency?

Contact us for help mobilizing your site, or to sign up for our beta Mobile Web SDK!
all groups > c# > november 2009 >

c# : Counting the number of subscribers to a controls events



Steve Wilkinson
7/18/2005 7:52:05 AM
Is there any method I can use to determine the number of subscribers to a
controls events.

In particular I'm looking at the ComboBox.SelectedIndexChanged event, I have
a scenario where I need to cancel the SelectedIndexChanged event and restore
the original SelectedIndex property. To do this I unsubscribe the
SelectedIndexChanged event, update the SelectedIndex property and then
re-subscribe. I need to do this to prevent the SelectedIndexChanged event
from firing twice (i.e once when the user changes the control and twice when
the code restores the original value).

I don't want to maintain a flag as the entire user interface is generated
dynamically.

Therefore I need a method to check how many subscribers there are to the
SelectedIndexChanged event before I attempt to add another subscription.

Any ideas would be appreciated.

Steve Wilkinson
7/18/2005 8:35:06 AM
Nicholas,

Thanks for the reply.

I will have to think of another approach.

Steve

[quoted text, click to view]
Nicholas Paldino [.NET/C# MVP]
7/18/2005 11:21:17 AM
Steve,

You aren't going to be able to do this without deriving from a class and
overriding the OnSelectedIndexChanged method, not calling the base class
(which fires the event). Removing all of the subscribers then re-attaching
them is something you really shouldn't be doing, as you are wasting a ton of
extra processing cycles.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com

"Steve Wilkinson" <SteveWilkinson@discussions.microsoft.com> wrote in
message news:79E882E9-DD3F-438B-A27D-CBB2DE508923@microsoft.com...
[quoted text, click to view]

piyush kashyap
11/4/2009 12:54:46 PM
enter teh value

From http://www.google.co.in/search?q=how+to+cancel+combobox+selectedindexchanged+c%23&hl=en&sa=2

Posted via DevelopmentNow.com Groups
AddThis Social Bookmark Button