Change Cursor on Cell Mouse Enter, Mouse Leave

3 posts, 1 answers
  1. Gone2TheDogs
    Gone2TheDogs avatar
    66 posts
    Member since:
    May 2016

    Posted 29 Nov 2016 Link to this post

    As there is no event for Cell Mouse Enter or Cell Mouse Leave for a GridView, What event can I use to change the Mouse Cursor when the mouse hovers over a specific Cell?

    I tried using the CellFormatting event to no avail.


    01.Private Sub dgvVenItems_CellFormatting(sender As Object, e As Telerik.WinControls.UI.CellFormattingEventArgs) Handles dgvVenItems.CellFormatting
    02.    Dim font As New System.Drawing.Font(SystemFonts.DialogFont, FontStyle.Underline)
    04.    If e.CellElement.ColumnIndex = 0 Then
    05.        e.CellElement.ForeColor = System.Drawing.Color.Blue
    06.        e.CellElement.Font = font
    07.        dgvVenItems.Cursor = Cursors.Hand
    08.    Else
    09.        e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, ValueResetFlags.Local)
    10.        dgvVenItems.Cursor = Cursors.Default
    11.    End If
    12.End Sub
  2. Answer
    Dimitar avatar
    2949 posts

    Posted 30 Nov 2016 Link to this post

    Hi Bob,

    Thank you for writing.

    You can use the CellMouseMove event:
    Private Sub RadGridView1_CellMouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
        Dim hoveredElement = radGridView1.ElementTree.GetElementAtPoint(e.Location)
        If TypeOf hoveredElement Is GridDataCellElement Then
            Dim cell = TryCast(hoveredElement, GridDataCellElement)
            If cell.Value IsNot Nothing AndAlso cell.Value.ToString() = "Sam" Then
                radGridView1.Cursor = Cursors.Hand
                radGridView1.Cursor = Cursors.Default
            End If
        End If
    End Sub

    I hope this will be useful. Let me know if you have additional questions.

    Telerik by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
  3. Gone2TheDogs
    Gone2TheDogs avatar
    66 posts
    Member since:
    May 2016

    Posted 30 Nov 2016 in reply to Dimitar Link to this post

    Great example. Thank you!


Back to Top