This is a migrated thread and some comments may be shown as answers.

Change Cursor on Cell Mouse Enter, Mouse Leave

2 Answers 418 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Gone2TheDogs asked on 29 Nov 2016, 03:05 PM

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)
03. 
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 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 30 Nov 2016, 07:40 AM
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
        Else
            radGridView1.Cursor = Cursors.Default
        End If
 
    End If
End Sub

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

Regards,
Dimitar
Telerik by Progress
Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
0
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
answered on 30 Nov 2016, 10:59 AM

Great example. Thank you!

 

Tags
GridView
Asked by
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Answers by
Dimitar
Telerik team
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Share this question
or