Hallo!
We have a grid with hidden rows and columns and "disjunctrowselect = true". Now we want to remove the selected rows.
- With RemoveRows():
MyGrid.BeginUpdate;
for i := 0 to MyList.Count - 1 do
begin
RowIndex := GetRowIndex(MyList[i]);
MyGrid.RemoveRows(RowIndex, 1);
end;
MyGrid.EndUpdate;
It removes them correctly, but has really bad performance, because it removes row by row and redraws the Grid every time.
- With RemoveSelectedRows():
MyGrid.BeginUpdate;
MyGrid.RemoveSelectedRows;
MyGrid.EndUpdate;
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;
Any idea why? In this topic ( Memory leak on TAdvStringGrid - #7 by Duffy_David ) it seems, that it can be necessary to "clearrows" because of this.
Thanks