|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
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 FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
type
Fishoil=Record
name:String;
sex:String;
age:Integer;
end;
var
i:Integer=1;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
With StringGrid1 do
begin
cells[0,0]:='姓名';
cells[1,0]:='性别';
cells[2,0]:='年龄';
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
fishc1:Fishoil;
begin
if i<6 then
begin
fishc1.name :=InputBox('昵称','请输入'+IntToStr(i)+'个账号的昵称 ','');
fishc1.sex :=InputBox('性别','请输入'+IntToStr(i)+'个账号的性别 ','');
fishc1.age :=StrToInt(InputBox ('年龄','请输入'+IntToStr(i)+'个账号年龄 ',''));
With StringGrid1 do
begin
cells[0,i]:=fishc1.name;
cells[1,i]:=fishc1.sex;
cells[2,i]:=IntTOStr(fishc1.age);
end;
Inc(i);
end
Else
ShowMessage('数据已满,请清空后重新输入');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i,j:Integer;
begin
For i:=1 to 5 do
begin
For j:=0 to 2 do
begin
StringGrid1.cells[j,i]:='';
end;
end;
end;
end.
|
|