Changing datagridview cell color dynamically

后端 未结 5 541
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 11:04

I have a dataGridView object that is populated with data. I want to click a button and have it change the color of the background of the cell. This is what I currently have<

5条回答
  •  失恋的感觉
    2020-11-29 11:39

    Considere use DataBindingComplete event for update the style. The next code change the style of the cell:

        private void Grid_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            this.Grid.Rows[2].Cells[1].Style.BackColor = Color.Green;
        }
    

提交回复
热议问题