Back to Devexpress

RepositoryItemProgressBar.PercentView Property

windowsforms-devexpress-dot-xtraeditors-dot-repository-dot-repositoryitemprogressbar.md

latest5.1 KB
Original Source

RepositoryItemProgressBar.PercentView Property

Gets or sets whether to present the current position as a relative value between the RepositoryItemProgressBar.Minimum and RepositoryItemProgressBar.Maximum and format it as a percentage. The RepositoryItemBaseProgressBar.ShowTitle property must be set to true.

Namespace : DevExpress.XtraEditors.Repository

Assembly : DevExpress.XtraEditors.v25.2.dll

NuGet Package : DevExpress.Win.Navigation

Declaration

csharp
[DefaultValue(true)]
[DXCategory("Behavior")]
public bool PercentView { get; set; }
vb
<DXCategory("Behavior")>
<DefaultValue(True)>
Public Property PercentView As Boolean

Property Value

TypeDefaultDescription
Booleantrue

true to present the current position as a relative value; false to present the current position as an absolute value.

|

Remarks

Set the RepositoryItemBaseProgressBar.ShowTitle property to true to display text in the progress bar.

To apply custom formatting to the control’s value, use the RepositoryItem.DisplayFormat property.

To provide a custom display text, handle the RepositoryItem.CustomDisplayText event.

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.

csharp
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");
vb
Imports System.IO
Imports DevExpress.XtraEditors.Controls
' ...
Private Sub DeleteFiles(ByVal source As String)
   If Directory.Exists(source) Then
      Dim fileEntries As String() = 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
      For Each fileName As String In fileEntries
         File.Delete(fileName)
         progressBarControl1.PerformStep()
         progressBarControl1.Update()
      Next fileName
   End If
End Sub
' ...
DeleteFiles("d:\Temp")

See Also

ShowTitle

RepositoryItemProgressBar Class

RepositoryItemProgressBar Members

DevExpress.XtraEditors.Repository Namespace