Ошибки есть , но не понимаю где

Надо транспонировать матрицу. 3 кнопки обязательно. С помощью 1 заполняем массив рандом, с помощью 2 кнопки сами и третья это транспонирование. Почти работает .
Код:
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, StdCtrls;
type
TForm7 = class(TForm)
Lbl_n: TLabel;
edt_n: TEdit;
Button1: TButton;
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
Lbl_V: TLabel;
Btn_Random: TButton;
Btn_SAM: TButton;
ext: TButton;
procedure Button1Click(Sender: TObject);
procedure Btn_RandomClick(Sender: TObject);
procedure Btn_SAMClick(Sender: TObject);
procedure StringGrid1KeyPress(Sender: TObject; var Key: Char);
procedure extClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
n,x,y: integer;
arr: array [1..100, 1..100] of integer;
implementation
{$R *.dfm}
procedure TForm7.Btn_RandomClick(Sender: TObject);
Var i:integer;
begin
n:=STRtoInt(edt_n.Text) ;
StringGrid1.RowCount := n;
StringGrid1.ColCount := n;
randomize;
for x := 1 to n-1 do
for y := 1 to n-1 do
arr[x,y]:=-10 + random(100);
Begin
for x := 0 to n-1 do
for y := 0 to n-1 do
StringGrid1.Cells[x,y]:=InttoStr(arr[y,x]) ;
End;
end;
procedure TForm7.Btn_SAMClick(Sender: TObject);
begin
StringGrid1.fixedcols:=0 ;
StringGrid1.fixedrows:= 0 ;
n:=STRtoInt(edt_n.Text) ;
StringGrid1.RowCount := n;
StringGrid1.ColCount := n;
stringGrid1.Options:=stringGrid1.Options+[goEditing];
end;
procedure TForm7.Button1Click(Sender: TObject);
var
i:integer;
begin
n:=STRtoInt(edt_n.Text) ;
StringGrid2.RowCount := n;
StringGrid2.ColCount := n;
begin
for x := 0 to n-1 do
for y := 0 to n-1 do
StringGrid2.Cells[x,y]:=IntToStr(arr[x,y]);
end;
end;
procedure TForm7.extClick(Sender: TObject);
begin
close;
end;
procedure TForm7.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
case Key of
'0'..'9', #8: ; // цифры и Backspace
'-' : if Length(StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row]) <> 0 then Key:=Char(0);
else Key:= Char(0); // Остальные символы не отображать
end;
end;
end.
Админ: Теги и еще раз теги! При рецедиве последует бан.