Re: Clearing Delphi stringgrid

Posted by Jim on May 08, 2007

In Reply to Re: Clearing stringgrid posted by Sharon on May 05, 2007

: : How do you add data to the stringgrid? I assume 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;

: Yes I add data by using row:=row+1;

: Thankyou for your help Jim but I still can't get the code to work. When adding your suggested line I am presented with the following error message:

: [Error] Unit2.pas(115): Undeclared identifier: 'StringGrid1'.

: Perhaps I am not writing the code correctly. Here is what I put:

: 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]:='';
: StringGrid1.RowCount := 1;
: end;

: Any glaring mistakes?
------------

Sorry, my mistake... try it with:
form1.StringGrid1.RowCount := 1;

instead of:
StringGrid1.RowCount := 1;

That's because I didn't notice that your declaration is:
procedure clear_grid;

...and I assumed that it was:
procedure form1.clear_grid;

Well, that's why Delphi is called OOP, "object"-oriented-programming ;)

Good luck!
Jim

Related articles

       

Follow Ups