我使用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