GetCellCoordAt(Pt: IPoint): IPoint;
Pt. Coordinates of the points, 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 - to the string 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 string will be available in X and Y correspondingly.
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 strings (area where strings can be created), then the X coordinate will be set to -1, and the Y coordinate will contain the number of already created strings.
If the sent point is in the empty area to the right of all columns (area where the columns can be created), then the X coordinate will be set to -1, and the Y coordinate will contain the string index.
If the sent point is in the empty area at the level of headers, then 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 is hovered over the DataGrid1 component, the development environment console displays coordinates of the hovered cell.
See also: