Mehmet Fatih

Mehmet Fatih

  • 746
  • 904
  • 30.9k

Progressbar percentage

Aug 11 2023 1:28 PM

I'm trying to show progress bar as much as the amount of records marked in the checkbox column. But I couldn't.

if (dataGridView1.Rows.Count > 100)
{
    int total = 500; /
    for (int i = 0; i <= total; i++)
    {
        System.Threading.Thread.Sleep(100);
        int percents = (i * 100) / total;
        backgroundWorker1.ReportProgress(percents, i);
    }
}
else if (dataGridView1.Rows.Count < 100)
{
    int total = 100;
    for (int i = 0; i <= total; i++)
    {
        System.Threading.Thread.Sleep(50);
        int percents = (i * 100) / total;
        backgroundWorker1.ReportProgress(percents, i);
    }
}

 


Answers (6)