DataGridView changing cell background color

后端 未结 10 1630
没有蜡笔的小新
没有蜡笔的小新 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:57

    I finally managed to get it working. Here the code :

    private void dgvStatus_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
    {
        if (e.ColumnIndex != color.Index)
            return;
    
        e.CellStyle.BackColor = Color.FromArgb(int.Parse(((DataRowView)dgvStatus.Rows[e.RowIndex].DataBoundItem).Row[4].ToString()));
    }
    

    if anyone know a better to do this please don't hesitate to post it. I'm open to suggestion

提交回复
热议问题