西月 发表于 2013-2-15 16:39:44

表格问题!

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 :=Edit1.Text ;
    StringGrid1.Cells :=Edit2.Text ;
    StringGrid1.Cells :=Edit3.Text ;
    StringGrid1.Cells :=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:= '语文';
    StringGrid1.Cells:= '数学';
    StringGrid1.Cells:= '英语';

end;

end.
为什么我的表格框框是这个样子的!!!

页: [1]
查看完整版本: 表格问题!