unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 =
class
(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Button2: TButton;
procedure
Button1Click(Sender: TObject);
procedure
Button2Click(Sender: TObject);
procedure
StringGrid1Click(Sender: TObject);
private
public
end
;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure
TForm1
.
Button1Click(Sender: TObject);
var
i:
integer
;
temp,temp1:
string
;
begin
if
(StringGrid1
.
ColCount
mod
2
=
1
)
then
temp1 := StringGrid1
.
Cells[StringGrid1
.
colcount-
1
,
0
];
for
i :=
0
to
stringgrid1
.
ColCount
div
2
do
begin
temp := stringgrid1
.
Cells[
2
*i,
0
];
StringGrid1
.
Cells[
2
*i,
0
]:= StringGrid1
.
Cells[
2
*i+
1
,
0
];
StringGrid1
.
Cells[
2
*i+
1
,
0
] := temp;
end
;
if
(StringGrid1
.
ColCount
mod
2
=
1
)
then
StringGrid1
.
Cells[StringGrid1
.
colcount-
1
,
0
] := temp1;
end
;
procedure
TForm1
.
Button2Click(Sender: TObject);
var
i:
integer
;
begin
randomize;
for
i:=
0
to
StringGrid1
.
ColCount-
1
do
StringGrid1
.
Cells[i,
0
] := inttostr(random(
128
));
end
;
end
.