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

Change cursor on cell hover issue

1 Answer 412 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jacob
Top achievements
Rank 1
Jacob asked on 26 May 2017, 07:33 AM

Hello Telerik,

I came across a scenario of which i need to change the mouse cursor (from pointer to hand) if the user hovers a specific type of cell.

After browsing your forums, I found the following solution:

 

GridControl.AddHandler(MouseMoveEvent, new MouseEventHandler(OnMouseMove), true);
private void OnMouseMove(object sender, MouseEventArgs e)
{
    var cell = (e.OriginalSource as FrameworkElement).ParentOfType<GridViewCell>();
    if (cell != null)
    {
        switch (cell.Column.UniqueName)
        {
            case "UserName":
                Mouse.OverrideCursor = Cursors.Hand;
                break;
            default:
                Mouse.OverrideCursor = Cursors.Arrow;
                break;
        }
    }
    else
    {
        Mouse.OverrideCursor = Cursors.Arrow;
    }
}

 

 

It works, however, the cursor will remain a pointer when trying to resize the column widths.

is there an easy way to prevent this? to have the user being able to resize the columns once again?

 

Thank you

1 Answer, 1 is accepted

Sort by
0
Jacob
Top achievements
Rank 1
answered on 26 May 2017, 09:04 AM

I managed to find the easiest solution: 
                Mouse.OverrideCursor = null

instead of Arrow.

works fine

Tags
GridView
Asked by
Jacob
Top achievements
Rank 1
Answers by
Jacob
Top achievements
Rank 1
Share this question
or