【发布时间】:2019-02-27 04:26:04
【问题描述】:
我有这段代码,我有一个 ProgressBar,我想在标签中写下我的 progressBar 百分比。如何在 foreach 循环中执行此操作?这是我的代码:
prg.Style = ProgressBarStyle.Continuous;
con.Open();
//insignificant sql and listbox operations...
prg.Value = 0;
prg.Maximum = myDataTable.Rows.Count;
foreach (DataRow myRows5 in myDataTable.Rows)
{
dgv.Rows.Add(...);
prg.Value++;
Application.DoEvents();
lbl.Text = "Loading... %" + Convert.ToString("I will put here of percentage...");
}
注意:百分比形式为 int percent = ((prg.Value / prg.Maximum) * 100)
谢谢...
【问题讨论】:
标签: c# datagridview datatable progress-bar