System.Windows.Forms.ProgressBar Class

Represents a Windows progress bar control.

See Also: ProgressBar Members

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.ComponentModel.DefaultBindingProperty("Value")]
[System.ComponentModel.DefaultProperty("Value")]
public class ProgressBar : Control

Remarks

A System.Windows.Forms.ProgressBar control visually indicates the progress of a lengthy operation in one of three styles:

The ProgressBar.Style property determines the style of System.Windows.Forms.ProgressBar that is displayed. Note that the System.Windows.Forms.ProgressBar control can only be oriented horizontally. For an example of how to create a vertically oriented System.Windows.Forms.ProgressBar, see the System.Windows.Forms.ProgressBarRenderer class. The System.Windows.Forms.ProgressBar control is typically used when an application performs tasks such as copying files or printing documents. Users of an application might consider an application unresponsive if there is no visual cue. By using the System.Windows.Forms.ProgressBar in your application, you alert the user that the application is performing a lengthy task and that the application is still responding.

The ProgressBar.Maximum and ProgressBar.Minimum properties define the range of values to represent the progress of a task. The ProgressBar.Minimum property is typically set to a value of 0, and the ProgressBar.Maximum property is typically set to a value indicating the completion of a task. For example, to properly display the progress when copying a group of files, the ProgressBar.Maximum property could be set to the total number of files to be copied.

The ProgressBar.Value property represents the progress that the application has made toward completing the operation. The value displayed by the System.Windows.Forms.ProgressBar only approximates the current value of the ProgressBar.Value property. Based on the size of the System.Windows.Forms.ProgressBar, the ProgressBar.Value property determines when to display the next block or increase the size of the bar.

There are a number of ways to modify the value displayed by the System.Windows.Forms.ProgressBar other than changing the ProgressBar.Value property directly. You can use the ProgressBar.Step property to specify a specific value to increment the ProgressBar.Value property by, and then call the ProgressBar.PerformStep method to increment the value. To vary the increment value, you can use the ProgressBar.Increment(int) method and specify a value with which to increment the ProgressBar.Value property.

Note:

Control.ForeColor and Control.BackColor changes for the System.Windows.Forms.ProgressBar will not be honored when visual styles are enabled on winxpfamily and above.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0