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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top