GetCellCoordAt(Pt: IPoint): IPoint;
Pt. Coordinates of the point, in which a component cell must be obtained.
The GetCellCoordAt method transforms coordinates of the specified point into component cell coordinates.
The X coordinate in the received point will correspond to the column index, the Y will correspond to the row index. Depending on which component area the point corresponds, the following options are available:
If the sent point is in the cell area, then column index and cell rows will be available in X and Y respectively.
If the sent point is in the table header area, only the X coordinate will be available and -1 will be returned as the Y coordinate value.
If the sent point is in the empty area below all rows (area where rows can be created), the X coordinate will be set to -1, and the Y coordinate will contain the number of already created rows.
If the sent point is in the empty area to the right of all columns (area where the columns can be created), the X coordinate will be set to -1, and the Y coordinate will contain the row index.
If the sent point is in the empty area at the level of headers, the X and Y coordinates will be set to -1.
Executing the example requires a form and the DataGrid component named DataGrid1 on the form.
Sub DataGrid1OnMouseMove(Sender: Object; Args: IMouseEventArgs);
Var
cell: IPoint;
Begin
cell := DataGrid1.GetCellCoordAt(Args.pPoint);
If (cell.X <> -1) And (cell.Y <> -1) Then
Debug.WriteLine(cell.X.ToString + " " + cell.Y.ToString);
End If;
End Sub DataGrid1OnMouseMove;
If the mouse cursor is hovered over the DataGrid1 component, the development environment console displays coordinates of the hovered cell.
See also: