Articles in this section

How to display hand cursor hovering over column in WinForms DataGrid?

In WinForms DataGrid (SfDataGrid), the default cursor that appears when hovering over a column is the arrow cursor. However, this behavior can be customized to display a hand cursor when the mouse hovers over a column and revert to the default arrow cursor when the mouse leaves. This can be achieved by handling the MouseMove event of the TableControl, where the cursor is set to Cursors.Hand when hovering over a valid column and reset to Cursors.Arrow otherwise.

// Event subscription
sfDataGrid1.TableControl.MouseMove += OnTableControlMouseMove;

//Event Customization
private void OnTableControlMouseMove(object? sender, MouseEventArgs e)
{
    // Get the row and column index at the mouse position
    var rowColumnIndex = sfDataGrid1.TableControl.PointToCellRowColumnIndex(e.Location);

    // Check if mouse is over a valid column
    if (rowColumnIndex.ColumnIndex > -1)
    {
        // Change to hand cursor when hovering over the columns
        Cursor = Cursors.Hand;
    }
    else
    {
        // Reset cursor to default when not over any column
        Cursor = Cursors.Arrow;
    }
}

HandCursor


Take a moment to peruse the WinForms DataGrid - Events documentation, where you can find about the events with code examples.


View sample in GitHub


 Conclusion


I hope you enjoyed learning how to display hand cursor hovering over column in WinForms DataGrid.

You can refer to our WinForms DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started with configuration specifications. You can also explore our WinForms DataGrid example to understand how to create and manipulate data.


For current customers, check out our components from the License and Downloads page. If you are new to Syncfusion, try our 30-day free trial to check out our other controls.


Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied