It removes them instantly without performance issues. But now if we close our application, which frees the grid, we get an invalid pointer exception here:
procedure TBaseGrid.SetCellProperties(c, r: integer; const Value: TCellProperties);
begin
if Assigned(inherited Objects[c,r]) then
TCellProperties(inherited Objects[c,r]).Free;
inherited Objects[c,r] := Value <---- Invalid Pointer here!
end;
Are you using cell properties to begin with? If you use cell properties, you might try to clear these rows first before removing with grid.ClearRows()
Removing rows one by one is a bad idea. It requires row re-arranging for every single call to remove a row.
You can also remove multiple rows at once with the grid.RemoveRowList() method.
Thanks for the fast reply.
For some context:
We use cellproperties to colorize our rows gray(rowfontcolor). In this special case all gray rows, which fulfill a certain condition, are hidden. If I unhide all those row and then delete a row it works. If I hide all gray rows and then delete a row it doesnt work (=if I destroy my form I get the exception in the TBaseGrid-function).
ClearRows() also didnt help (with MyGrid.ClearRows(1, MyGrid.AllRowCount-1)).
Is there a way to clear all cellproperties maybe?
ClearRows() does destroy the cell property objects. If a problem persists, please isolate & send a sample source project with which we can reproduce this.
An alternative could be to use OnGetCellColor to handle your coloring of cells to avoid using cell properties (which is also more memory friendly)