We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to have a hand cursor on a specified column of datagrid

Hello, On a datagrid, i try to have a hand cursor when the mouse in hover the second column. The code after don't work ! coud you help me please ..... Private Sub DataGrid1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles DataGrid1.MouseMove Dim hti As System.Windows.Forms.DataGrid.HitTestInfo hti = DataGrid1.HitTest(e.X, e.Y) If hti.Type = System.Windows.Forms.DataGrid.HitTestType.Cell Then If hti.Column = 1 Then Cursor.Current = System.Windows.Forms.Cursors.Hand End If End If End Sub

1 Reply

SM Scott Montgomerie June 13, 2005 06:32 PM

I have struggled with this for about a day now... I was trying to set event handlers on the MouseMove and MouseLeave events, but I kept getting a flickering in the icon, and it looked like I was fighting with the grid to set the Cursor. I discovered that it was trying to set the cursor to the MouseControllerDispatcher''s DisplayCursor, which was null. It turns out the proper way to fix this is to implement IMouseController: internal class MouseControllerDescendant: IMouseController { } my_grid.MouseControllerDispatcher.Add(new MouseControllerDescendant()); This class then implements a bunch of methods like HitTest, MouseHover, MouseEnter, etc., instead of using the usual event handlers. Hope this helps somebody and saves them a day of frustration! Cheers

Live Chat Icon For mobile
Up arrow icon