)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to change the ProgressStyle dynamically in WinForms ProgressBarAdv?

Platform: WinForms |
Control: ProgressBarAdv |
Published Date: April 30, 2011 |
Last Revised Date: January 7, 2020

ValueChanged event

You can handle the ValueChanged event and change the ProgressStyle depending on the value.

C#

private void timer1_Tick(object sender, System.EventArgs e)
{
    if (this.progressBarAdv1.Value<100)
        this.progressBarAdv1.Value++;
    else
        this.progressBarAdv1.Value = 0;
}
private void progressBarAdv1_ValueChanged(object sender, Syncfusion.Windows.Forms.Tools.ProgressBarValueChangedEventArgs e)
{
    if(this.progressBarAdv1.Value >0 && this.progressBarAdv1.Value <15)
    {
        this.progressBarAdv1.ProgressStyle =Syncfusion.Windows.Forms.Tools.ProgressBarStyles.Tube ;
     }
     if(this.progressBarAdv1.Value >15 && this.progressBarAdv1.Value <30)
     {
        this.progressBarAdv1.ProgressStyle =Syncfusion.Windows.Forms.Tools.ProgressBarStyles.Gradient ;
      }
     else if(this.progressBarAdv1.Value >30 && this.progressBarAdv1.Value <50)
     {
        this.progressBarAdv1.ProgressStyle =Syncfusion.Windows.Forms.Tools.ProgressBarStyles.MultipleGradient;
     }
     else if(this.progressBarAdv1.Value >50)
     {
        this.progressBarAdv1.ProgressStyle =Syncfusion.Windows.Forms.Tools.ProgressBarStyles.Image ;
     }
}

VB

Private Sub timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles timer1.Tick
    If Me.progressBarAdv1.Value < 100 Then
       Me.progressBarAdv1.Value += 1
    Else
       Me.progressBarAdv1.Value = 0
    End If
End Sub
Private Sub progressBarAdv1_ValueChanged(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Tools.ProgressBarValueChangedEventArgs) Handles progressBarAdv1.ValueChanged
    If Me.progressBarAdv1.Value > 0 AndAlso Me.progressBarAdv1.Value < 15 Then
       Me.progressBarAdv1.ProgressStyle = Syncfusion.Windows.Forms.Tools.ProgressBarStyles.Tube
    End If
    If Me.progressBarAdv1.Value > 15 AndAlso Me.progressBarAdv1.Value < 30 Then
       Me.progressBarAdv1.ProgressStyle = Syncfusion.Windows.Forms.Tools.ProgressBarStyles.Gradient
    ElseIf Me.progressBarAdv1.Value > 30 AndAlso Me.progressBarAdv1.Value < 50 Then
       Me.progressBarAdv1.ProgressStyle = Syncfusion.Windows.Forms.Tools.ProgressBarStyles.MultipleGradient
    ElseIf Me.progressBarAdv1.Value > 50 Then
        Me.progressBarAdv1.ProgressStyle = Syncfusion.Windows.Forms.Tools.ProgressBarStyles.Image
    End If
 End Sub
End Class

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon