|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
根据小甲鱼delphi第17讲动态数组的上机练习要求编写的程序,初学入门,各位大神多多指教
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids, ExtCtrls;
type
TForm1 = class(TForm)
pnl1: TPanel;
strngrd1: TStringGrid;
txt1: TStaticText;
edt1: TEdit;
btn1: TButton;
btn2: TButton;
txt2: TStaticText;
txt3: TStaticText;
txt4: TStaticText;
edt2: TEdit;
edt3: TEdit;
edt4: TEdit;
procedure FormCreate(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
var
person: Integer = 0;
currt: Integer = 0;
cj_arr: array of array of string;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
person:= StrToInt(InputBox('请输入', '请输入总人数: ', ''));
btn1.Caption:= '成绩录入' + '(' + IntToStr(currt) + '/' + IntToStr(person) + ')';
btn2.Enabled:= False;
SetLength(cj_arr, 4, person);
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
currt:= currt + 1;
cj_arr[0][currt-1]:= edt1.Text;
cj_arr[1][currt-1]:= edt2.Text;
cj_arr[2][currt-1]:= edt3.Text;
cj_arr[3][currt-1]:= edt4.Text;
edt1.Text:= '';
edt2.Text:= '';
edt3.Text:= '';
edt4.Text:= '';
btn1.Caption:= '成绩录入' + '(' + IntToStr(currt) + '/' + IntToStr(person) + ')';
if (currt = person) then
begin
btn2.Enabled:= True;
btn1.Enabled:= False;
edt1.Enabled:= False;
edt2.Enabled:= False;
edt3.Enabled:= False;
edt4.Enabled:= False;
end;
end;
procedure TForm1.btn2Click(Sender: TObject);
var
i,j: Integer;
begin
strngrd1.RowCount := person + 1;
strngrd1.Cells[1,0]:= '语文';
strngrd1.Cells[2,0]:= '英语';
strngrd1.Cells[3,0]:= '数学';
strngrd1.Height:= ( person + 1 ) * strngrd1.DefaultRowHeight + 10;
strngrd1.Width:= 360;
for i:= 0 to (person-1) do
begin
for j:= 0 to 3 do
begin
strngrd1.Cells[j,i+1]:= cj_arr[j][i];
end;
end;
strngrd1.Visible:= True;
end;
end.
inputbox
录入界面
|
评分
-
查看全部评分
|