TdxSpreadSheetTableView.CellAtPoint(TPoint,Integer,Integer,Boolean,Boolean) Method
Identifies a cell located at the specified position.
Declaration
procedure CellAtPoint(const P: TPoint; out ARow: Integer; out AColumn: Integer; AReturnNearestCell: Boolean = False; AVisibleAreaOnly: Boolean = True); overload;
Parameters
Name | Type | Description |
---|---|---|
P | TPoint | A position within the active worksheet. |
ARow | Integer | A row index of the cell located at the specified position within the active worksheet. |
AColumn | Integer | A column index of the cell located at the specified position within the active worksheet. |
AReturnNearestCell | Boolean | Specifies if the procedure returns row and column indexes of the cell nearest to the specified point even if it is located outside the worksheet content area. |
AVisibleAreaOnly | Boolean | Specifies if the procedure limits its search area to the currently displayed portion of the active worksheet. |
Remarks
Call this procedure and pass a point within the worksheet area as the P parameter to obtain row and column indexes of the cell located at this position. The P.X and P.Y field values specify the absolute horizontal and vertical point offsets (in pixels) within the active worksheet whose Options.ZoomFactor property is set to 100. If you call the CellAtPoint procedure to identify a cell under the mouse pointer, you need to transform the mouse pointer position into the worksheet coordinate system to obtain a correct cell regardless of the zoom factor:
var
ARow, AColumn: Integer;
APoint: TPoint;
begin
// Obtains the mouse pointer position
APoint := dxSpreadSheet1.ScreenToClient(GetMouseCursorPos);
// Transforms the mouse pointer position into the worksheet coordinate system
APoint := cxPointScale(APoint, 100, dxSpreadSheet1.ActiveSheetAsTable.Options.ZoomFactor);
// Obtains row and column indexes of the cell under the mouse pointer regardless of the zoom factor
dxSpreadSheet1.ActiveSheetAsTable.CellAtPoint(APoint, ARow, AColumn);
end;
The ARow and AColumn parameters return row and column indexes of the cell located under the specified point. If it is located within a row or column header cell, the CellAtPoint procedure returns a negative index value (-1) as the corresponding parameter. You can pass True as the AReturnNearestCell optional parameter to avoid negative row and column indexes even if the specified point is within a header cell.
The CellAtPoint procedure’s search area is limited to the currently visible portion of the active worksheet. You can set the optional AVisibleAreaOnly parameter to False to include the entire worksheet into the search area.
Note
Call the CellAtPoint(TPoint,TdxSpreadSheetCell,Boolean,Boolean) procedure variant if you need to obtain a cell object located at the specified point.