Skip to Content

Work with ProgressBar

Working with ProgressBar (System.Windows.Forms.ProgressBar) control we processing some items. In such case typically we write cycle and initialize ProgressBar with current progress value. Once i got idea to simplify this.

Normally every ProgressBar has such value members:

  1. int Minimum
  2. int Maximum
  3. int Value
We can do cycle like this:
for (
      progressBar.Value = progressBar.Minimum = 0, progressBar.Maximum = 1000;
      progressBar.Value < progressBar.Maximum;
      DoSomething ();

In this way no any aditional variables needed to work with progress.