Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-01

Using StrindGrid

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

berna uyanık

Hi,
I started lazarus newly
Codes that I used is below:
unit Unit1;

{$mode objfpc}{$H+}
interface

uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Grids;

type

{ TForm1 }

TForm1 = class(TForm)
grid1: TStringGrid;
procedure FormCreate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
var satir: integer;
sutun:integer;
begin
for sutun:=1 to grid1.ColCount do;
begin
grid1.cells[sutun,0]:=chr(64+sutun);
end;
for satir:=1 to grid1.RowCount do;
begin
grid1.Cells[0,satir]:=inttostr(satir);
end;
end;
initialization
{$I unit1.lrs}
end.

I wanted to give nembers and letters to row and column sides.

After I had runned those codes I received "Index Out of range Cell[Col=5 Row=0].

Where is my mistake?
Thanks for all.

John & Marg Sunderland
to berna uyanık
berna uyan?k wrote 39 lines
Hi, I started lazarus newly Codes that I used is below: unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Grids; type { TForm1 } TForm1 = class(TForm) grid1: TStringGrid; procedure FormCreate(Sender: TObject); private { private declarations } public { public declarations } end; var Form1: TForm1; implementation { TForm1 } procedure TForm1.FormCreate(Sender: TObject); var satir: integer; sutun:integer; begin for sutun:=1 to grid1.ColCount do;
Try
for sutun:=0 to grid1.ColCount - 1 do .....

grid rows and cols are 0 indexed, so if you have 3 cols, they are numbered from 0 to 2, not 1 to 3.

You will find this in lots of places.

cheers,

John Sunderland