Reputation: 23
What I have tried, The below line of code changes a complete column background color.
dataGridView.Columns[1].DefaultCellStyle.BackColor = Color.Yellow;
But, I want to work the same for only a selected row. For example, I have 4 columns in datagridview, and when I select the row. Selected rows should have a different background color for every column.
This is how am getting a selected row.
foreach (DataGridViewRow dvr in dataGridView.SelectedRows)
{
dvr.Cells[0].Value.ToString();
}
I am able to get the cell value of the selected row but I can't access the cell value back color property.
Any idea how I can do this. Please help
Upvotes: 2
Views: 605