鱼C论坛

 找回密码
 立即注册
查看: 2382|回复: 0

表格问题!

[复制链接]
发表于 2013-2-15 16:39:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. unit Unit14;

  2. interface

  3. uses
  4.   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  5.   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.StdCtrls, Vcl.ExtCtrls;

  6. type
  7.   TForm14 = class(TForm)
  8.     Label1: TLabel;
  9.     Button1: TButton;
  10.     Button2: TButton;
  11.     Label2: TLabel;
  12.     Label3: TLabel;
  13.     Label4: TLabel;
  14.     StringGrid1: TStringGrid;
  15.     Panel1: TPanel;
  16.     Edit1: TEdit;
  17.     Edit2: TEdit;
  18.     Edit3: TEdit;
  19.     Edit4: TEdit;
  20.     procedure FormCreate(Sender: TObject);
  21.     procedure Button1Click(Sender: TObject);
  22.     procedure Button2Click(Sender: TObject);
  23.   private
  24.     { Private declarations }
  25.   public
  26.     { Public declarations }
  27.   end;

  28. var
  29.   Form14: TForm14;
  30.   RowCount:Integer;
  31.   x:Integer=1;
  32. implementation

  33. {$R *.dfm}

  34. procedure TForm14.Button1Click(Sender: TObject);
  35. begin
  36.     if (Trim(Edit1.Text) <>'')and(Trim(Edit2.Text) <>'')and(Trim(Edit3.Text) <>'')and(Trim(Edit4.Text) <>'') then
  37.     begin
  38.     StringGrid1.Cells [0,x]:=Edit1.Text ;
  39.     StringGrid1.Cells [1,x]:=Edit2.Text ;
  40.     StringGrid1.Cells [2,x]:=Edit3.Text ;
  41.     StringGrid1.Cells [3,x]:=Edit4.Text ;
  42.     x:=x+1;
  43.     Button1.Caption :=IntToStr(x-1)+'/'+IntToStr(RowCount-1);
  44.     end
  45.     Else
  46.   begin
  47.     MessageBox(handle, '输入错误', '提示', MB_OK or MB_ICONSTOP);
  48.   end;
  49.     if (x= Rowcount) then
  50.     begin
  51.       Button1.Enabled := false;
  52.       Button2.Enabled := True;
  53.     end;
  54.     Edit1.Text :='';
  55.     Edit2.Text :='';
  56.     Edit3.Text :='';
  57.     Edit4.Text :='';
  58. end;

  59. procedure TForm14.Button2Click(Sender: TObject);
  60. begin
  61.     StringGrid1.Visible :=True;
  62. end;

  63. procedure TForm14.FormCreate(Sender: TObject);
  64. var
  65.     str:String;

  66. begin
  67.     str:=InputBox('提醒','请输入录入成绩的人数','');
  68.     Form14.AutoSize :=true;
  69.     Button2.Enabled :=False;
  70.     StringGrid1.Visible :=false;
  71.     StringGrid1.ColCount :=4;
  72.     StringGrid1.RowCount := StrToInt(str)+1;
  73.     Rowcount:= StrToInt(str)+1;
  74.     StringGrid1.Cells  [1,0]:= '语文';
  75.     StringGrid1.Cells  [2,0]:= '数学';
  76.     StringGrid1.Cells  [3,0]:= '英语';

  77. end;

  78. end.
复制代码
QQ截图20130215163522.jpg
  为什么我的表格  框框是这个样子的!!!

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-4 02:41

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表