Progress bar in C#

December 2016


I am creating a program which runs a parameterized query to add 14,370 records to a table. The downside is that it takes about 15 seconds. I would use a progressbar to show the user the progress of the execution of the query. I need an example.


Create a winform with a GroupBox1, a label and a button that is outside the GroupBox.
  • Put the Text property of the GroupBox in an empty string.
  • Put the property of AutoSize to False, the color of the label to Lime for example.
  • The Size property is set to 0, 15
  • Code:

int counter=0;
int rowMax=2000;
int colMax=2000;
decimal pcdDone;
for(int r=0;r<rowMax;r++)
for(int c=0;c<colMax;c++)
groupBox1.Text=((int)(pcdDone*100)).ToString() +"%";

Thanks to OUROBANGNA for this tip.

Related :

This document entitled « Progress bar in C# » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.