This documentation is archived and is not being maintained.

Introduction to the Windows Forms ProgressBar Control

Visual Studio .NET 2003

The Windows Forms ProgressBar control indicates the progress of a process by displaying an appropriate number of rectangles arranged in a horizontal bar. When the process is complete, the bar is filled. Progress bars are commonly used to give the user an idea of how long to wait for a protracted process to complete — for instance, when a large file is being loaded.

The key properties of the ProgressBar control are Value, Minimum, and Maximum. The Minimum and Maximum properties set the maximum and minimum values the progress bar can display. The Value property represents the progress that has been made toward completing the operation. Because the bar displayed in the control is composed of blocks, the value displayed by the ProgressBar control only approximates the Value property's current value. Based on the size of the ProgressBar control, the Value property determines when to display the next block.

The most common way to update the current progress value is to write code to set the Value property. In the example of loading a large file, you might set the maximum to the size of the file in kilobytes. For example, if the Maximum property is set to 100, the Minimum property is set to 10, and the Value property is set to 50, then 5 rectangles will be displayed — which will be half of the number that can be displayed.

However, there are other ways to modify the value displayed by the ProgressBar control, aside from setting the Value property directly. The Step property can be used to specify a value to increment the Value property by. Then, calling the PerformStep method will increment the value. To vary the increment value, you can use the Increment method and specify a value with which to increment the Value property.

Another control that graphically informs the user about a current action is the StatusBar control. For more information, see Introduction to the Windows Forms StatusBar Control.

See Also

ProgressBar Control (Windows Forms) | ProgressBar Class