Display Hand cursor on Datagridview Cell Hover

Niladri.Biswas
Posted by Niladri.Biswas under C# category on | Points: 40 | Views : 9058
I have a requirement where on the second column (including header) of Datagridview, the mouse cursor will be changed to hand.The CellMouseEnter event of DataGridView control can be used for this purpose as shown below

private void dataGridView1_CellMouseEnter(object sender, DataGridViewCellEventArgs e) 
{

var dataGridView = (sender as DataGridView);

if (e.ColumnIndex == 2)
{
dataGridView.Cursor = Cursors.Hand;
}
else
{
dataGridView.Cursor = Cursors.Default;
}
}

Comments or Responses

Login to post response