Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make an endless progressbar in WinForms?

I don't know how long an action could take and I want to display a progress bar to the user in a dialog box. I've tried using System.Windows.Forms.ProgressBar but it doesn't seem to support it.

An example of what I'd want is the progress bar that windows shows you when it's looking for new drivers on the internet. It's just got three or four 'bars' going back and forth marquee style on the progress bar.

How can I do this?

like image 511
Malfist Avatar asked Mar 11 '09 19:03

Malfist


People also ask

How do you make a ProgressBar in Winforms?

To create a ProgressBar control at design-time, you simply drag a ProgressBar control from the Toolbox and drop onto a Form in Visual Studio. After you the drag and drop, a ProgressBar is created on the Form; for example the ProgressBar1 is added to the form and looks as in Figure 1.

What is the default step value of ProgressBar?

Property Value The amount by which to increment the progress bar with each call to the PerformStep() method. The default is 10.

How do you determine the range of values that a ProgressBar can show?

The ProgressBar provides options for setting its value or a range of values and for indicating the progress of an ongoing task. To set the value of the ProgressBar, use its value option. To define the start and end values of the range, use the min and max ProgressBar settings respectively.


2 Answers

System.Windows.Forms.ProgressBar has a property called Style. Setting Style to Marquee will achieve the effect your looking for.

EDIT: Divo points out the Marquee Style is only available on

Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003

The comments provide even more information indicating that this appears to work everywhere as long as you're using .NET 2.0 or higher.

like image 53
Mykroft Avatar answered Sep 22 '22 19:09

Mykroft


Have you tried setting the Style property of the System.Windows.Forms.ProgressBar to Marquee?

However, surprisingly, this property is only available on the following platforms (according to MSDN):

Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003

Might be that the documentation has not been updated to Vista though. Anyone knows about a limitation on Vista?

EDIT: As posted in another comment the documentation seems to be wrong with respect to the supported platforms. Should be working on Vista as well as Windows 7.

like image 31
Dirk Vollmar Avatar answered Sep 21 '22 19:09

Dirk Vollmar