|
-
Jul 3rd, 2021, 12:48 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How to get a progress bar changes from its previous step?
Hi all 
Consider a progress bar which supposed to indicate a quality for instance.
How can I get a three state thing which states that this progress bar is fixed, increasing or decreasing?
In mathematics there's a way in which you calculate differences between current x(t) and its one step retard x(t-1). I wasn't successful to get my previous progress bar value due to "value change" event is not available for this control.
If anyone know a trick to rectify this matter I will be so much appreciated. ♥ Thanks in advanced
-
Jul 4th, 2021, 02:24 AM
#2
Re: How to get a progress bar changes from its previous step?
It's really remarkable how many people think that the ProgressBar control is magic. It's not. It is simply a visual representation of a ratio. That's it, that's all. If you want to know whether the Value property increased, decreased or remained the same when you last set it then you do the obvious thing: you compare the old value to the new value. That's it, that's all. It's your code that changes that property so just get the value before changing it instead of expecting the control to tell you what it was.
One option my be to avoid using that property at all and create a custom control with a dedicated method and an extra property:
vb.net Code:
Public Class ProgressBarEx
Inherits ProgressBar
Private _previousValue As Integer
Public ReadOnly PreviousValue As Integer
Get
Return _previousValue
End Get
End Property
Public Sub SetValue(newValue As Integer)
_previousValue = Value
Value = newValue
End Sub
End Class
You can then use that instead of the regular ProgressBar, call SetValue instead of setting the Value property directly and then get PreviousValue in the ValueChanged event handler. Of course, if you're going to do that, you could also move the calculation inside as well, exposing the change direction via a property of an Enum type.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|