主题:不知道怎么改错!!!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, Grids, Spin;
type
TForm1 = class(TForm)
ColSpinEdit: TSpinEdit;
RowSpinEdit: TSpinEdit;
StringGrid1: TStringGrid;
Label1: TLabel;
Label2: TLabel;
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure ColSpinEditChange(Sender: TObject);
procedure RowSpinEditChange(Sender: TObject);
procedure ColSpinEditkeyPress(Sender: TObject;var Key: char);
procedure FormCreate(Sender: TObject);
procedure StringGridMouseDown(Sender: TObject;Button:TMouseButton;
Shift:TShiftState;X,Y:Integer);
private
{ Private declarations }
procedure DrawCells(ss:TStringGrid;var ww:integer);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.DrawCells(ss:TStringGrid;var ww;integer);
var
r,c:integer;
begin
with ss as TStringGrid do
begin
Options:=Options+[goEditing];//使网格处于编辑状态
for r:=1 to ColCount do
for c:=1 to RowCount do
begin
if ww=1 then
cells[c,r]:='' //将网格清空
else if ww=2 then //按顺序写数
cells[c,r]:=inttostr((r-1)*(colCount-1)+(c));
end;
Options:=Options-[goEditing]; //使网格不能编辑
end;
end;
procedure TForm1.ColSpinEditChange(Sender:TObject);
begin
StringGrid1.ColCount:=Strtoint(colspinedit.Text);//网格的列数与colspinedit有关
end;
procedure TForm1.RowSpinEditChange(Sender:TObject);
begin
stringgrid1.RowCount:=strtoint(rowspinedit.Text);//网格的行数与rowspinedit有关
end;
procedure TForm1.ColSpinEditkeyPress(Sender:TObject;var key:char);
begin
key:=#0;//使对colspinedit的输入无效
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
kk,jj:integer;
begin
kk:=1;
jj:=2;
if radiobutton1.Checked then
begin
Form1.DrawCells(stringgrid1,kk);
Form1.DrawCells(stringgrid1,jj);
end
else Form1.DrawCells(stringgrid1,kk);
end;
procedure TForm1.FormCreate(Sender:TObject);
begin
with stringgrid1 do
begin
colspinedit.Text:=inttostr(colcount);//初始化spinedit
rowspinedit.Text:=inttostr(rowcount);
end;
end;
procedure TForm1.StringGridMouseDown(Sender: TObject;
Button:TMouseButton;Shift:TShiftState;X,Y:integer);
var
n,m:integer;
begin
stringgrid1.Options := stringgrid1.Options+[goediting];
stringgrid1.MouseToCell(X,Y,n,m);//获取列数和行数
stringgrid1.Cells[n,m]:='行'+inttostr(m)+',列'+inttostr(n);
stringgrid1.Options:=stringgrid1.Options-[goediting];
end;
end.
当我运行时它说:
procedure TForm1.DrawCells(ss:TStringGrid;var ww;integer);
[error]unit1.pas[42]:missing parameter type
请问怎么解决?
我用到的组件有
spinedit
radiogroup
bitbtn
stringgrid
radiobutton
label
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, Grids, Spin;
type
TForm1 = class(TForm)
ColSpinEdit: TSpinEdit;
RowSpinEdit: TSpinEdit;
StringGrid1: TStringGrid;
Label1: TLabel;
Label2: TLabel;
RadioGroup1: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure ColSpinEditChange(Sender: TObject);
procedure RowSpinEditChange(Sender: TObject);
procedure ColSpinEditkeyPress(Sender: TObject;var Key: char);
procedure FormCreate(Sender: TObject);
procedure StringGridMouseDown(Sender: TObject;Button:TMouseButton;
Shift:TShiftState;X,Y:Integer);
private
{ Private declarations }
procedure DrawCells(ss:TStringGrid;var ww:integer);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.DrawCells(ss:TStringGrid;var ww;integer);
var
r,c:integer;
begin
with ss as TStringGrid do
begin
Options:=Options+[goEditing];//使网格处于编辑状态
for r:=1 to ColCount do
for c:=1 to RowCount do
begin
if ww=1 then
cells[c,r]:='' //将网格清空
else if ww=2 then //按顺序写数
cells[c,r]:=inttostr((r-1)*(colCount-1)+(c));
end;
Options:=Options-[goEditing]; //使网格不能编辑
end;
end;
procedure TForm1.ColSpinEditChange(Sender:TObject);
begin
StringGrid1.ColCount:=Strtoint(colspinedit.Text);//网格的列数与colspinedit有关
end;
procedure TForm1.RowSpinEditChange(Sender:TObject);
begin
stringgrid1.RowCount:=strtoint(rowspinedit.Text);//网格的行数与rowspinedit有关
end;
procedure TForm1.ColSpinEditkeyPress(Sender:TObject;var key:char);
begin
key:=#0;//使对colspinedit的输入无效
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
kk,jj:integer;
begin
kk:=1;
jj:=2;
if radiobutton1.Checked then
begin
Form1.DrawCells(stringgrid1,kk);
Form1.DrawCells(stringgrid1,jj);
end
else Form1.DrawCells(stringgrid1,kk);
end;
procedure TForm1.FormCreate(Sender:TObject);
begin
with stringgrid1 do
begin
colspinedit.Text:=inttostr(colcount);//初始化spinedit
rowspinedit.Text:=inttostr(rowcount);
end;
end;
procedure TForm1.StringGridMouseDown(Sender: TObject;
Button:TMouseButton;Shift:TShiftState;X,Y:integer);
var
n,m:integer;
begin
stringgrid1.Options := stringgrid1.Options+[goediting];
stringgrid1.MouseToCell(X,Y,n,m);//获取列数和行数
stringgrid1.Cells[n,m]:='行'+inttostr(m)+',列'+inttostr(n);
stringgrid1.Options:=stringgrid1.Options-[goediting];
end;
end.
当我运行时它说:
procedure TForm1.DrawCells(ss:TStringGrid;var ww;integer);
[error]unit1.pas[42]:missing parameter type
请问怎么解决?
我用到的组件有
spinedit
radiogroup
bitbtn
stringgrid
radiobutton
label