Progress Bar looping iteration issue

  • Thread starter Thread starter Gani tpt
  • Start date Start date
G

Gani tpt

Guest
I am using progress bar in my C# win form application.

normally i am using many for loops and each for loop will have more than 1000 (thousand) iterations.

for example, below i am using 3 for loops and will have 100o iterations.

when i use the progress bar for every loop, the count will not come perfect.

For first loop, i will set "40%",

Second loop, will have maximum "40%"

Third Loop, will have maximun "20%".

All the loops should be executed within 100%.

But, In my code, First loop will be executing 100%. even though 100% completed still it is running first loop.


How to split the progress bar percentage while using separate loop.

below is the code

progbar1.Minimum = 0;
progbar1.Maximum = 40;
progbar1.Step = 1;
//progbar1.Value = 0;
int idxcount1 = 1;
foreach (DataRow DR in dtTable1.Rows) //Total Rows = 1000 rows
{

progbar1.Value = idxcount1;
idxcount1++;
} //Here it should take and show only "40%" of all the rows executed

progbar1.Maximum = 80;
progbar1.Step = 1;
//progbar1.Value = 0;
int idxcount2 = 1;
foreach (DataRow DR in dtTable2.Rows) //Total Rows = 1000 rows
{

progbar1.Value = idxcount2;
idxcount2++;
} //Here it should take and show only "40%" of all the rows executed

progbar1.Maximum = 80;
progbar1.Step = 1;
//progbar1.Value = 0;
int idxcount3 = 1;
foreach (DataRow DR in dtTable3.Rows) //Total Rows = 500 rows
{

progbar1.Value = idxcount3;
idxcount3++;
} //Here it should take and show only "20%" of all the rows executed

Continue reading...
 
Back
Top