Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

datagridview cell mouse hover backcolor change

i want to change the backcolor of cell in datagridview while mouse hover on particular cell.

Tried code:

private void dataGridView_whateventwillcomehere(object sender, DataGridViewCellEventArgs e)
        {

        }
like image 802
user3747256 Avatar asked Oct 28 '25 18:10

user3747256


1 Answers

Try this on CellMouseMove Event

private void dataGridView1_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e)
{
    dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.Blue;
}

You need CellMouseLeave Event to restore color

private void dataGridView1_CellMouseLeave(object sender, DataGridViewCellEventArgs e)
{
    dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Style.BackColor = Color.White;
}
like image 200
NASSER Avatar answered Oct 31 '25 07:10

NASSER



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!