我有一个DataGridView,最多可包含56000行对,最多可评估20列。我必须遍历DGV,然后循环每个单元以验证其是否匹配,如果不匹配,则将背景色设置为红色。我显示一个带有x记录的计数器i的面板,其中i是迭代的当前值。要获得新的i值以显示我必须执行applicaiton.doevent()。这会使一切变慢。例如,1000行10列的时间大约需要5-7秒,而计数器没有向上计数,但是计数器运行时大约需要45秒。有没有更快的方法来处理柜台?
与计数器相比,速度要慢5-10倍,而没有计数器则非常快
private void newErrorValidation(List<string> lstColName, DataTable _dtErrors)
{
int intDtRow = -1;
string strDtErrorColval = null;
foreach (DataRow drError in _dtErrors.Rows)
{
intDtRow = Convert.ToInt16(drError["row"]);// this is the row being checked from the errortable not the dgvrowid
for (int i = 0; i < dgvMatchErrors.RowCount; i++)
{
if (dgvMatchErrors.Rows[i].Cells["row"].Value.ToString() == Convert.ToString(intDtRow))
{
for (int l = 3; l < lstColName.Count; l++)
{
if (drError[lstColName[l].ToString()].ToString() == "False")
{
dgvMatchErrors.Rows[i].Cells[lstColName[l].ToString()].Style.BackColor = Color.Red;
}
}
updateStatuslbl(i, dgvMatchErrors.RowCount);
Application.doevent();
}
}
}
}
我想向用户展示代码在处理中的位置。