Windows Forms ProgressBar: Easiest way to start/stop marquee?

Mark Stahler picture Mark Stahler · Nov 23, 2008 · Viewed 214.9k times · Source

I am using C# and Windows Forms. I have a normal progress bar working fine in the program, but now I have another operation where the duration cannot be easily calculated. I would like to display a progress bar but don't know the best way to start/stop the scrolling marquee. I was hoping for something as simple as setting the marquee speed and then having a start() and stop() but it doesn't appear to be that simple. Do I have to run an empty loop in the background? How do I best do this? Thanks

Answer

Paul Fisher picture Paul Fisher · Nov 23, 2008

Use a progress bar with the style set to Marquee. This represents an indeterminate progress bar.

myProgressBar.Style = ProgressBarStyle.Marquee;

You can also use the MarqueeAnimationSpeed property to set how long it will take the little block of color to animate across your progress bar.