Is the IsEmptyRow function inherited from a parent class of stringgrid? It doesn't seem to be part of the stringgrid itself?
It's a protected function of TCustomGrid.
Unfortunately it is not virtual so you cannot override it.
Just duplicate the code as needed.
function TCustomGrid.IsEmptyRow(ARow: Integer): Boolean;
var
i: Integer;
begin
Result := False;
for i:=FixedCols to ColCount-1 do
if GetCells(i, ARow)<>'' then begin
Exit;
end;
Result := True;
end;
Instead of
if GetCells(i, ARow)<>'' then
use
if Trim(GetCells(i, ARow))<>'' then //this will retrun true if GetCells retruns only whitespace
Could you please elaborate on or point to where BeginUpdate and EndUpdate are documented?
Imagine you have a large grid and you want to update many cells.
var
Grid: TStringGrid;
...
begin
Grid.BeginUpdate;
try
for R := 0 to Grid.RowCount-1 do
begin
for C := 0 to Grid.ColCount-1 do
begin
Grid.Cells[C,R] := '*'+Cells[C,R]+'*';
end;
end;
finally
Grid.EndUpdate
end;//try..finally
end;
If you leave out the BeginUpdate/EndUpdate, after each Grid.Cells[C,R] := '*'+Cells[C,R]+'*', the Grid will redraw it's contents to the screen.
This will cause a lot of flicker and it will take more time.
If you use BeginUpdate/EndUpdate, the Grid will not draw anything until EndUpdate is called.
This is also why you need to use the try..finally construct, otherwise if an exception occurs EndUpdate is never called, and the Grid does not draw anymore to the screen.
Bart