110,533
社区成员
发帖
与我相关
我的任务
分享
private void insertData(BackgroundWorker worker)
{
if (dataGridView1.Rows.Count > 0)
{
for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
{
kygcsh.yhbh = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value.ToString());
kygcsh.czje = Convert.ToDecimal(dataGridView1.Rows[i].Cells[2].Value.ToString());
try
{
HXX.kyygtianjiajine(kygcsh);
//3.调用worker的ReportProgress函数,用来引发事件ProgressChanged
worker.ReportProgress(i, worker);
}
catch
{
MessageBox.Show("插入数据有误,请正确输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
MessageBox.Show("初始化成功!", "提示");
}
else
{
MessageBox.Show("没有可初始化记录!", "提示");
}
}
double p=i/this.dataGridView1.Rows.Count;
不就是你需要的的百分比吗