Hi,
In my winform (4.0) I am using datagridview.
On hovering over the cells, the colour of the cell changes to yellow.
The DataGridViewCellStyle of the datagridview is set to : { BackColor=Color [A=255, R=244, G=244, B=244] }
The mouse goes over the cell which has an existing colour, then cell changes to yellow, BUT when the mouse moves away from the cell, the cell looses it's previous colour.
How can the cell have the same colour as before it turned yellow?
Thanks
private void dgv_CellMouseEnter(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex > -1 && e.RowIndex > -1)
{
if (dgv[e.ColumnIndex, e.RowIndex].Value != null)
{
if (dgv[e.ColumnIndex, e.RowIndex].Style.BackColor == Color.SkyBlue)
{
}
else
{
dgv[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.Gold;
}
}
}
}
private void dgv_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex > -1 && e.RowIndex > -1)
{
if (dgv[e.ColumnIndex, e.RowIndex].Value != null)
{
if (dgv[e.ColumnIndex, e.RowIndex].Style.BackColor == Color.SkyBlue)
{
}
else
{
dgv[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.White;
}
}
}
}