|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- unit Unit14;
- interface
- uses
- Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
- Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls, Vcl.ExtCtrls;
- type
- TForm14 = class(TForm)
- Label1: TLabel;
- Button1: TButton;
- Button2: TButton;
- Label2: TLabel;
- Label3: TLabel;
- Label4: TLabel;
- StringGrid1: TStringGrid;
- Panel1: TPanel;
- Edit1: TEdit;
- Edit2: TEdit;
- Edit3: TEdit;
- Edit4: TEdit;
- procedure FormCreate(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form14: TForm14;
- RowCount:Integer;
- x:Integer=1;
- implementation
- {$R *.dfm}
- procedure TForm14.Button1Click(Sender: TObject);
- begin
- if (Trim(Edit1.Text) <>'')and(Trim(Edit2.Text) <>'')and(Trim(Edit3.Text) <>'')and(Trim(Edit4.Text) <>'') then
- begin
- StringGrid1.Cells [0,x]:=Edit1.Text ;
- StringGrid1.Cells [1,x]:=Edit2.Text ;
- StringGrid1.Cells [2,x]:=Edit3.Text ;
- StringGrid1.Cells [3,x]:=Edit4.Text ;
- x:=x+1;
- Button1.Caption :=IntToStr(x-1)+'/'+IntToStr(RowCount-1);
- end
- Else
- begin
- MessageBox(handle, '输入错误', '提示', MB_OK or MB_ICONSTOP);
- end;
- if (x= Rowcount) then
- begin
- Button1.Enabled := false;
- Button2.Enabled := True;
- end;
- Edit1.Text :='';
- Edit2.Text :='';
- Edit3.Text :='';
- Edit4.Text :='';
- end;
- procedure TForm14.Button2Click(Sender: TObject);
- begin
- StringGrid1.Visible :=True;
- end;
- procedure TForm14.FormCreate(Sender: TObject);
- var
- str:String;
- begin
- str:=InputBox('提醒','请输入录入成绩的人数','');
- Form14.AutoSize :=true;
- Button2.Enabled :=False;
- StringGrid1.Visible :=false;
- StringGrid1.ColCount :=4;
- StringGrid1.RowCount := StrToInt(str)+1;
- Rowcount:= StrToInt(str)+1;
- StringGrid1.Cells [1,0]:= '语文';
- StringGrid1.Cells [2,0]:= '数学';
- StringGrid1.Cells [3,0]:= '英语';
- end;
- end.
复制代码
为什么我的表格 框框是这个样子的!!!
|
|