TStringGrid.Clear (deletes all cells in a stringgrid)

Catalin80
Catalin80 used Ask the Experts™
on
I need a method ("Clear") that clears all cells of a string grid and then deletes them.

So stringgrid.Clear finally DELETES ALL CELLS (ROWS/COLS..whatever you like) of the stringgrid.

Thx.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2004

Commented:
just set the rowcount- and colcount-properties to 0 (zero)

meikl ;-)

Author

Commented:
Already tryed that. Doesn't work. (delphi6)

Author

Commented:
There is still 1 cell left.
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Commented:
Do you meant the content only?

procedure ClearStringGrid(Grid: TStringGrid);
var
  I: Integer;
  J: Integer;
begin
  for I := 0 to Grid.ColCount-1 do
    for J := 0 to Grid.RowCount-1 do
      Grid.Cells[I,J] := '';
end;

Author

Commented:
The content AND the CELLS. I need one tstringgrid WITH NO CELLS. If that isn't possible then I just can hide the entire table.
Top Expert 2004

Commented:
there allways one cell!
you can't get rid of it

Author

Commented:
Ok. but what was that about "colcont=0;rowcount=0" ?
Top Expert 2004

Commented:
>but what was that about "colcont=0;rowcount=0" ?
that deletes the whole content from the grid,
that one cell left is a default painting bahaviour, if the grid is empty
-> maybe this could be adjusted by using ownerdraw

meikl ;-)
Commented:
if the grid is empty, just make it invisible. Then you'll have no cell at all.

try setting the stringgrids visible property to false when u want to get rid of them all

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial