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";
     }
}
文章標籤

丫烈客 發表在 痞客邦 留言(0) 人氣(972)