DataGridview 本身並沒有 類似 RowDataBound 的Event 可以用 CellFormatting 來取代 範例: void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
string val = e.Value.ToString();
if (e.RowIndex > -1 && e.ColumnIndex >= -1 && val != null && val=="2")
{
e.CellStyle.BackColor = Color.Red;
e.Valaue="Red";
}
}
{
string val = e.Value.ToString();
if (e.RowIndex > -1 && e.ColumnIndex >= -1 && val != null && val=="2")
{
e.CellStyle.BackColor = Color.Red;
e.Valaue="Red";
}
}