ProgressBarControl Class
The control that indicates the progress of a lengthy operation.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v18.1.dll
Declaration
[ToolboxBitmap(typeof(ToolboxIconsRootNS), "ProgressBarControl")]
[ToolboxTabName("DX.18.1: Common Controls")]
[DefaultBindingPropertyEx("Position")]
public class ProgressBarControl :
ProgressBarBaseControl
Remarks
This class represents a progress bar control used to indicate the progress of a lengthy operation or operation rate, etc. The progress bar control is typically used when an application performs tasks such as copying files or printing documents. The image below shows the control’s appearance.
The ProgressBarControl.Position property specifies the position of the indicator representing the progress that the application has made towards completing a particular task. Methods provided by the ProgressBarControl class can be used to manipulate the indicator’s position. The ProgressBarControl.PerformStep method advances the indicator’s position by the RepositoryItemProgressBar.Step property value. The ProgressBarControl.Increment and ProgressBarControl.Decrement methods allow you to increase and decrease the control’s value (position) by a specified value.
The ProgressBarControl.Properties property accesses a RepositoryItemProgressBar object which provides a number of properties, methods and events controlling the control’s appearance and behavior.
Example
In the code fragment below, a DeleteFiles method removes all files contained within the directory specified by the source parameter. The ProgressBarControl is used to display the progress of file delete operations. The RepositoryItemProgressBar.Minimum and RepositoryItemProgressBar.Maximum properties are used to specify a range for the progress bar that is equivalent to the number of files to be removed. The code also uses the RepositoryItemProgressBar.Step property with the ProgressBarControl.PerformStep method, to increment the position of the progress bar as soon as a file is removed.
using System.IO;
using DevExpress.XtraEditors.Controls;
// ...
private void DeleteFiles(string source){
if (Directory.Exists(source)){
string[] fileEntries = Directory.GetFiles(source);
// Initializing progress bar properties
progressBarControl1.Properties.Step = 1;
progressBarControl1.Properties.PercentView = true;
progressBarControl1.Properties.Maximum = fileEntries.Length;
progressBarControl1.Properties.Minimum = 0;
// Removing the list of files found in the specified directory
foreach(string fileName in fileEntries){
File.Delete(fileName);
progressBarControl1.PerformStep();
progressBarControl1.Update();
}
}
}
// ...
DeleteFiles("d:\\Temp");
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the ProgressBarControl class.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.