Reputation: 4265
Hello I want to change the background color of a cell in a datagridview if its value changed.
I have written the onChange event like this:
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Columns[e.ColumnIndex].Name == "Version")
{
//Change Background
}
}
So how do I change the value of the changed cell now?
Upvotes: 0
Views: 1877
Reputation: 788
The DataGridViewCellEventArgs argument contains all you need here;
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.Columns[e.ColumnIndex].Name == "Version")
{
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.AliceBlue;
}
}
Upvotes: 3