DataGridView changing cell background color

后端 未结 10 1689
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 10:20

I have the following code :

private void dgvStatus_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
    foreach (DataGridViewRow          


        
10条回答
  •  心在旅途
    2020-11-30 10:43

    Simply create a new DataGridViewCellStyle object, set its back color and then assign the cell's style to it:

        DataGridViewCellStyle style = new DataGridViewCellStyle();
        style.BackColor = Color.FromArgb(((GesTest.dsEssais.FMstatusAnomalieRow)row.DataBoundItem).iColor);
        style.ForeColor = Color.Black;
        row.Cells[color.Index].Style = style;
    

提交回复
热议问题