With a DataGridView control on a Windows form, when you move the mouse over a row label (or column label) it\'s (the label cell) background changes to a shade of blue (or ot
I know you already have the response for this, but I will share something different.
This way, the whole row is painted. I just modified @BFree comments a little bit.
private void dataGridView1_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0 || e.ColumnIndex < 0) //column header / row headers
{
return;
}
foreach (DataGridViewCell cell in this.dataGridView1.Rows[e.RowIndex].Cells)
{
cell.Style.BackColor = Color.LightBlue;
}
}
private void dataGridView1_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0 || e.ColumnIndex < 0) //column header / row headers
{
return;
}
foreach (DataGridViewCell cell in this.dataGridView1.Rows[e.RowIndex].Cells)
{
cell.Style.BackColor = Color.White;
}
}