6
Answers

Progressbar percentage

Mehmet Fatih

Mehmet Fatih

1y
666
1

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)