: (4,4) .
:
1. .
2. file/new/application.
3. Standart Form1 : Button1, Button2, Button3. StringGrid1, StringGrid2.
.4. Form1 Caption . Button1, Button2, Button3 Caption 1, 2 .
Options. . doEditing=true
StringGrid1, StringGrid2 FixedCols=0
FixedRows=0
ColCount=4
RowCount=4
.
5. .
Button1:
procedure TForm1.Button1Click(Sender: TObject); var i:integer;
begin
for i:=0 to 3 do begin
StringGrid2.Cells[i,0]:=StringGrid1.Cells[i,3];
StringGrid2.Cells[i,3]:=StringGrid1.Cells[i,0];
StringGrid2.Cells[i,1]:=StringGrid1.Cells[i,1];
StringGrid2.Cells[i,2]:=StringGrid1.Cells[i,2]; end
end;
Button2:
procedure TForm1.Button2Click(Sender: TObject); begin StringGrid2.Rows[0]:=StringGrid1.Rows[3]; StringGrid2.Rows[1]:=StringGrid1.Rows[1]; StringGrid2.Rows[2]:=StringGrid1.Rows[2]; StringGrid2.Rows[3]:=StringGrid1.Rows[0];
end;
Button3
procedure TForm1.Button3Click(Sender: TObject); var i,j:integer;
begin
for i:=0 to 3 do for j:=0 to 3do
StringGrid2.Cells[j,i]:=' ' end;
6. unit Gulk; interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm) StringGrid1: TStringGrid; StringGrid2: TStringGrid; Button1: TButton; Button2: TButton; Button3: TButton;
procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private
{ Private declarations } public
{ Public declarations } end;
var
Form1: TForm1; implementation {$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); var i:integer;
begin
for i:=0 to 3 do begin
StringGrid2.Cells[i,0]:=StringGrid1.Cells[i,3];
StringGrid2.Cells[i,3]:=StringGrid1.Cells[i,0];
StringGrid2.Cells[i,1]:=StringGrid1.Cells[i,1];
StringGrid2.Cells[i,2]:=StringGrid1.Cells[i,2]; end
end;
procedure TForm1.Button2Click(Sender: TObject); begin StringGrid2.Rows[0]:=StringGrid1.Rows[3]; StringGrid2.Rows[1]:=StringGrid1.Rows[1]; StringGrid2.Rows[2]:=StringGrid1.Rows[2]; StringGrid2.Rows[3]:=StringGrid1.Rows[0];
end;
procedure TForm1.Button3Click(Sender: TObject); var i,j:integer;
begin
for i:=0 to 3 do for j:=0 to 3do
StringGrid2.Cells[j,i]:=' ' end;
end.
7. Run.