5
如何知道datagridview是否在其任何单元格上都有errorText。我有我想,如果所有单元格的值是有效的含义,没有一个细胞都ERRORTEXT设置检查dataGridView是否在其任何单元格上设置了errorText
如何知道datagridview是否在其任何单元格上都有errorText。我有我想,如果所有单元格的值是有效的含义,没有一个细胞都ERRORTEXT设置检查dataGridView是否在其任何单元格上设置了errorText
使用此方法对你的代码,只启用一个Save按钮:
private bool HasErrorText()
{
bool hasErrorText = false;
//replace this.dataGridView1 with the name of your datagridview control
foreach (DataGridViewRow row in this.dataGridView1.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
if (cell.ErrorText.Length > 0)
{
hasErrorText = true;
break;
}
}
if (hasErrorText)
break;
}
return hasErrorText;
}