2009-11-11 79 views
0

我想突出顯示DataGridView中的特定行。無法突出顯示DataGridView中的行

但下面的代碼是不工作:

foreach (DataGridViewRow row in DataGridView1.Rows) 
{ 
    if (row.Cells["Job No"].Value.ToString().Equals("Sub Total")) 
    { 
     row.DefaultCellStyle.BackColor = Color.Red;      
    } 
} 

任何想法?謝謝!

+0

什麼編語言? – Treby 2009-11-11 03:39:10

+0

我正在使用C#來執行此代碼 – aioria 2009-11-11 03:43:47

回答

0
foreach (DataGridViewRow row in DataGridView1.Rows) 
{ 
    if (row.Cells["Job No"].Value.ToString().Equals("Sub Total")) 
    { 
     DataGridView1.rows[row.index].DefaultCellStyle.BackColor = Color.Red; 
    } 
}