Skip to main content

TdxSpreadSheetTableView.CellAtPoint(TPoint,TdxSpreadSheetCell,Boolean,Boolean) Method

Returns a cell object located at the specified position.

Declaration

procedure CellAtPoint(const P: TPoint; out ACell: TdxSpreadSheetCell; AReturnNearestCell: Boolean = False; AVisibleAreaOnly: Boolean = True); overload;

Parameters

Name Type Description
P TPoint

A position within the active worksheet.

ACell TdxSpreadSheetCell

A cell object (an initialized cell) located at the specified position within the active worksheet. This parameter returns nil (in Delphi) or nullptr/NULL (in C++Builder) if there is no cell object at the specified position.

AReturnNearestCell Boolean

Specifies if the procedure returns the cell object 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 a cell object 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 obtain a cell object 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  
  ACell: TdxSpreadSheetCell;
  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 the cell object under the mouse pointer regardless of the zoom factor
  dxSpreadSheet1.ActiveSheetAsTable.CellAtPoint(APoint, ACell);
end;

The ACell parameter returns a cell object that corresponds to a cell located under the specified point. If you pass True as the AReturnNearestCell optional parameter, the ACell parameter returns the initialized cell nearest to the specified point, even if it is located outside the worksheet content area. The ACell parameter returns nil (in Delphi) or nullptr/NULL (in C++Builder) if the CellAtPoint procedure fails to find a cell object at the current conditions.

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,Integer,Integer,Boolean,Boolean) procedure variant if you need to identify a cell at the specified position by its row and column indexes.

See Also