• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Use of TStringGrid

An easy one...

How do I use the TStringGrid component?

Thanks in advance...
   Boomer Dragon
0
boomerdragon
Asked:
boomerdragon
1 Solution
 
daniel_cCommented:
What do you mean by that question?
What do you want to do with TStringGrid?
0
 
intheCommented:
hi,
drop stringtid onto form and in object insector set the goediting option to true;
run the project and type some stuff in grid..
thats it.
do whatecvver wit the text..
can save and load the grid to file like this:
procedure TForm1.Button1Click(Sender: TObject);
var
 f:textfile;
 x,y:integer;
begin
assignfile (f,'C:\STRING.TXT');
rewrite (f);
writeln (f,stringgrid1.colcount);
writeln (f,stringgrid1.rowcount);
For X:=0 to stringgrid1.colcount-1 do
For y:=0 to stringgrid1.rowcount-1 do
writeln (F, stringgrid1.cells[x,y]);
closefile (f);
END;
procedure TForm1.Button2Click(Sender: TObject);
var f:textfile;
temp,x,y:integer;
tempstr:string;
begin
assignfile (f,'c:\string.txt');
reset (f);
readln (f,temp);
stringgrid1.colcount:=temp;
readln (f,temp);
stringgrid1.rowcount:=temp;
For X:=0 to stringgrid1.colcount-1 do
 For y:=0 to stringgrid1.rowcount-1 do begin
         readln (F, tempstr);
 stringgrid1.cells[x,y]:=tempstr;
 end;
closefile (f);

end;


hope that help
Regards Barry
0
 
boomerdragonAuthor Commented:
Thank you very much. I'm trying to move from the VB world, and this StringGrid was a puzzle :-). I was looking for something like a "Format String". Now I know that makes no difference.

Thanks again!

Boomer Dragon
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now