⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit4.~pas

📁 通过一个界面实例
💻 ~PAS
字号:
unit Unit4;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, ExtCtrls, StdCtrls, Buttons;

type
  TForm4 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Panel3: TPanel;
    StringGrid1: TStringGrid;
    BitBtn1: TBitBtn;
    procedure addbutton;
    procedure FormShow(Sender: TObject);
    procedure ButtonClick(Sender:Tobject);
  private
    { Private declarations }
  public
    { Public declarations }
    MyButton:array of TButton;
    n:integer;//试题总数
    r,c:integer;//当前行号,列号
  end;

var
  Form4: TForm4;

implementation

{$R *.dfm}

procedure TForm4.addbutton;
begin
//动态生成按键
  mybutton[c]:=Tbutton.Create(form4.StringGrid1);
  mybutton[c].Parent:=form4.StringGrid1;
  mybutton[c].Name:='B'+inttostr(c);
  mybutton[c].ParentToClient(form4.StringGrid1.BoundsRect.TopLeft);
  mybutton[c].Left:=StringGrid1.ColWidths[1]+StringGrid1.ColWidths[1]+StringGrid1.ColWidths[1];
  mybutton[c].Top:=form4.StringGrid1.RowHeights[c-1];
  mybutton[c].Caption:='查看';
  mybutton[c].Width:=form4.StringGrid1.ColWidths[4];
  //mybutton[c].Height:=form4.StringGrid1.RowHeights[r];
  mybutton[c].OnClick:=form4.ButtonClick;
end;

procedure TForm4.ButtonClick(Sender: Tobject);
begin
//
end;

procedure TForm4.FormShow(Sender: TObject);
var l,m:integer;
begin
//
  l:=form4.StringGrid1.RowCount-1;
  SetLength(MyButton,l);
  for m:=1 to l do
  begin
    c:=m+1;
    form4.addbutton;
  end;


end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -