Delphi stringgrid Sample (Using for loop)

1. Open new Delphi  VCL application.
2. Drag and drop stringgrid component to the form.
3. Drag and drop Button component to the form.
4. Copy and past below code to the button "click" property.

procedure TForm1.Button1Click(Sender: TObject);
var i, ix :integer;
begin
StringGrid1.ColCount:=10;
StringGrid1.RowCount:=10;

for I := 0 to 10 do
for Ix := 0 to 10 do
  with StringGrid1 do
  begin

  Cells[i,ix] := 'Col - ' + inttostr(i) + ', Row - ' + inttostr(ix);
  ColWidths[i-1]:=100;

  end;

end;

5. Run the application.


Comments

Popular posts from this blog

How to save jpg image to database and then load it in Delphi using FIBplus and TImage?

Object Oriented Programming in Delphi A Guide for Beginners