Reputation: 125
I want to use a progressbar twice with two different buttons one by one. The problem if after the first reaches max value it won't start again from the other button.
Here is the code :
Private Sub CrystalClearButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalClearButton1.Click
Timer1.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ProgressBar1.Increment(10)
End Sub
Private Sub CrystalClearButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalClearButton2.Click
Timer2.Start()
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
ProgressBar1.Increment(10)
End Sub
Upvotes: 0
Views: 104
Reputation: 44921
The simple solution is to reset the value each time the button is clicked.
Here is one example:
Private Sub CrystalClearButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CrystalClearButton1.Click
ProgressBar1.Value = 0
Timer1.Start()
End Sub
Also, instead of setting to 0, you can ensure that if you change the Minimum
property on the progress bar, this code will continue to work by using the following code (if you are always going to use 0 as a minimum, then the previous code will be fine):
ProgressBar1.Value = ProgressBar1.Minimum
Upvotes: 2