# [SOLVED] Making a progress bar go backward



## Mattman86 (Sep 12, 2008)

Would this work to make the progress bar step back 1 every 15 seconds?


```
private void progressTimer_Tick(object sender, EventArgs e)
        {
            this.progressBar1.Step = -1;
            this.progressBar1.PerformStep();
            this.progressBar1.Step = 1;
        }
```


----------



## jamiemac2005 (Jul 5, 2007)

*Re: Making a progress bar go backward*



Mattman86 said:


> Would this work to make the progress bar step back 1 every 15 seconds?
> 
> 
> ```
> ...


Show us the rest of the code and I'm sure I can answer that. 

this.progressBar1.step = 1; looks like it doesn't do anything.

Cheers,
Jamey


----------



## Mattman86 (Sep 12, 2008)

*Re: Making a progress bar go backward*

I actually can't show you the code because the company I work for made me sign a confidentiality statement.

I can tell you though that I have a windows form written in c# in Visual Studio 2010. In this form, there is a progress bar that is stepped up one every time a certain event happens in the application. when the bar gets to 100, the process is supposed to stop. The progress bar is also supposed to go back one every 15 seconds. I have a timer that is set to tick every 15 seconds.


----------



## A1tecice (Jun 1, 2010)

*Re: Making a progress bar go backward*

Without at least some of the code we cant really answer your question im afraid.


----------



## Mattman86 (Sep 12, 2008)

*Re: Making a progress bar go backward*

Why not?

From what I said, anybody can assume that I have 2 objects... a timer set to tick at 15 seconds and a progress bar that is set to step 1 every time an event happens.

What I want to know is if by putting a -1 as the step then performing the step, will the bar go backwards?


----------



## Carpetfizz (Jul 5, 2011)

*Re: Making a progress bar go backward*

Why don't you just build and run and see if it works?


----------



## Crockeo (Apr 17, 2010)

*Re: Making a progress bar go backward*



Carpetfizz said:


> Why don't you just build and run and see if it works?


I really like that idea. . .


----------



## Emphyrio (May 16, 2009)

*Re: Making a progress bar go backward*



Mattman86 said:


> Would this work to make the progress bar step back 1 every 15 seconds?
> 
> 
> ```
> ...


So you stand still 




Make a WFA
Place a button, a Progressbar and the timer. 


```
using System;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            progressBar1.Value = 100;  // Set the bar full
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            progressBar1.Step = -1;
            progressBar1.PerformStep();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            timer1.Enabled = true; // when clicked, the progress goes backwards.
        }
    }
}
```
In your _timer1_ (on Form1.cs [Design]) set Interval on 15000 (=15 sec.)

Even better is to put this in a backgroudWorker.


----------



## Mattman86 (Sep 12, 2008)

*Re: Making a progress bar go backward*

This actually worked just fine for me.


```
private void progressTimer_Tick(object sender, EventArgs e)
        {
            this.progressBar1.Step = -1;
            this.progressBar1.PerformStep();  >>Go backward
            this.progressBar1.Step = 1;
        }
```
I never actually performed the step a second time so it only moved once.


----------

