Skip to main content

TdxSpreadSheetTableView.DeleteCells(string,TdxSpreadSheetCellsModification,TdxSpreadSheetTableViewMergedCellsConflictResolution) Method

Deletes the current cell selection or a specified cell range.

Declaration

procedure DeleteCells(const AArea: string; AModification: TdxSpreadSheetCellsModification; AMergedCellsConflictResolution: TdxSpreadSheetTableViewMergedCellsConflictResolution = mccrShowConfirmation); overload;

Parameters

Name Type
AArea string
AModification TdxSpreadSheetCellsModification
AMergedCellsConflictResolution TdxSpreadSheetTableViewMergedCellsConflictResolution

Remarks

DeleteCells removes the cell objects occupying the currently selected cell range. Neighboring cells are shifted left or up to populate the vacant space. If there are no selected cells within the current Table View worksheet, this procedure raises the EdxSpreadSheetError exception.

The second overloaded variant removes either an individual cell object or the cell objects within the range passed as the AArea parameter and shifts the cells left or up to populate the vacant space. The AModification parameter specifies behavior of the adjacent cells after calling the DeleteCells procedure. The optional AMergedCellsConflictResolution parameter allows you to specify how DeleteCells handles merged cells within the deleted area. By default, this procedure handles such a conflict by displaying the cell unmerge confirmation dialog (in the same manner as Excel):

The following code example demonstrates how to delete cell objects within the B2:B3 cell range. Neighboring cells are shifted to the left to populate the freed space. The appearance of the Table View worksheet before and after the code execution is displayed in the image below.

var
  ATableView: TdxSpreadSheetTableView;
//...
  ATableView := dxSpreadSheet1.ActiveSheetAsTable;
  ATableView.DeleteCells(Rect(1, 1, 1, 2), cmShiftCellsHorizontally);

If either the selected or specified cell range intersects the array formula result area, both DeleteCells overloaded variants raise the EdxSpreadSheetCannotChangePartOfArray exception.

To insert the specified number of cell objects into a Table View worksheet, use the InsertCells procedure.

Note

Invoking the DeleteCells method has no effect if the CanDelete function returns False.

See Also