StringGridColCount (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This code fills each cell with a number. The numbers are arranged in consecutive order by rows. Notice that even cells in the fixed rows and columns are altered.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
  I, J, K : Integer;
begin
  K := 0;
  with StringGrid1 do
    for I := 0 to ColCount - 1 do
      for J:= 0 to RowCount - 1 do
        begin
          K := K + 1;
          Cells[I,J] := IntToStr(K);
        end;
end;

Uses