Clearing stringgrid

Posted by Jim on May 01, 2007

In Reply to grid_clear posted by Sharon on April 20, 2007

: I have the following procedure to clear the cells of a stringgrid.

: procedure clear_grid;
: var row,col:integer;
: begin
: for row:=1 to 20 do
: for col:=0 to 5 do
: form1.StringGrid1.cells[col,row]:='';
: end;

: The procedure works fine, however, after clearing the grid and continuing to add data I want the new data to be added to the top of the grid i.e. cell 0,1. At the moment the data clears, and when I add new data it enters into the cells below those that have been cleared. Could anyone please help me?

: Sharon

How do you add data to the stringgrid? From your explanation, I assume that you add a row after the last existing row, that you do something like this:

StringGrid1.RowCount := StringGrid1.RowCount + 1;

If that's the case, simply add a line to your procedure clear_grid:

StringGrid1.RowCount := 1;

If that doesn't solve it, please show us the code by which you add new data.

Good luck!

Related articles


Follow Ups