Articles in this section
Category / Section

How to get the Row and Column Index of the cell from Mouse Point?

1 min read

In GridControl, you can get the Row and Column Index of a cell under the Mouse Point, by using PointToCellRowColumnIndex and PointToCellRowColumnIndexOutsideCells.

PointToCellRowColumnIndex:

This method allows you to get the Row and Column Index of a cell under the mouse point in GridControl, regardless of its position.

Syntax: PointToCellRowColumnIndex (Point p);

C#

Point pos =  Mouse.GetPosition(grid);
RowColumnIndex cell = grid.PointToCellRowColumnIndex(pos);

PointToCellRowColumnIndexOutsideCells:

This method allows you to get the Row and Column Index of the cell under the mouse point in GridControl. It also allows you to identify whether you have clicked inside the cell or points outside the cell, that is, Points over the Gridlines.

Syntax: PointToCellRowColumnIndexOutsideCells(Point p, bool allowOutsideLines)

C#

Point pos =  Mouse.GetPosition(grid);
RowColumnIndex cell = grid.PointToCellRowColumnIndexOutsideCells(pos, false);  

You can easily identify whether you have clicked at any point inside the cell or outside the cell by setting allowOutsideLines as False. It returns negative values for the points that are outside the cell.

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