我使用foreach循环来检查datagridview中每行的数据,我想避免标题和空buttom行,我该怎么做? 这是我简单的循环:如何循环datagridview全行
foreach (DataGridViewRow row in dataGridView1.Rows)
{
string datatocheck = row.Cells[2].Value.ToString();
if (datatocheck == "done")
{
row.Cells[2].Style.ForeColor = Color.Yellow;
}
}
使用工作循环来代替。 –
'if(!row.IsNewRow)...' – LarsTech