Creating Event to Monitor a Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have an integer value from a 3rd party control that looks something like
this:

MyControl.theValue

I need a way to detect when the value changes. My first thought is to use an
event. I could use a suggestion on how to wire the value change to an event
handler function.

Any thoughts?
Randy
 
Can you inherit from the control and override the method and have it raise
an event whenever set is called?
 
Short of polling on a worker thread, this is functionality that must
be provided by the 3rd-party. You could look for an "theValueChanged"
event (under standard naming relative to the property name), or
alternatively you could look to see if the class (control) implements
INotifyPropertyChanged, in which case try catching the PropertyChanged
event and watching for that property.

The other option (as per PokerMan) is to inherit, add the missing
event, and override the property to (additionally) trigger the event -
unless it is sealed of course. Or a field. Or not marked virtual.

Marc
 
Back
Top