Progress Bar Value Changed Event

stustarz

Junior Contributor
Joined
Jan 10, 2003
Messages
246
Location
Earth
I was hoping that the Progress Bar would have a value changed event, so i can handle whenever the progress bar's value has changed, but there isnt one, and doesnt seem to be any event that is raised each time the progress value is changed.

I am considering implementing this event in my own progress bar control, but is there any possible impact on having an event like this - i am thinking that possibly because a progress value could change from 1 - 1000 in the space of a second - this could cause a massive strain on the application seeing as it would have to raise 1000 value changed events, and then run the code handling it?

Any one have any thoughts on this?

Cheers
 
The reason it doesn't have a ValueChanged event is because you are the one who changes it's values.

I doubt thats the reason, im thinking more along the lines that its due to the number of events that could be raised within a short amount of time....If the reason was because of what you say, then why would the Textbox control have a TextChanged event?

I will go ahead and create the event in my custom progress control, and see whether there is a huge impact when raising the same event 100 times in 1 second :)
 
I think IngisKahn is right. With most controls the user is the one performing the action that results in an event being fired. With the progressbar, your code is in command of when the progress has to be updated so you don't need an event.

If you need this value change in another location, I would send an event in the place where the value is originally calculated. This event is then both subscribed to by the form that hosts the progressbar, and any other object that is interested.

The form will update the value of the progress bar when receiving that 'value changed event', the other object(s) that subscribed to the event can execute their own, specific, code.

That way you get your nice 1:n connection where the sender doesn't need to know who has subscribed to the event ;).

If you send the change event from the progress bar, it will work, but you add a level of indirection that isn't necessary I think.
 
Last edited:
The difference is that the user can change the value of a TextBox. The user can't change the value of a progress bar. Creating an event if you need one is fine. Be sure to test if the value actually changed before raising it.
 
Back
Top