unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure TSOnShow(Sender: TObject);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
P : TTabSheet;
begin
P := TTabSheet.Create(Self);
P.Caption := '测试页'+IntToStr(PageControl1.PageCount);
P.OnShow := TSOnShow; //给OnShow事件赋值
P.PageControl := PageControl1;
end;
//Onshow事件,就是一个方法而已
procedure TForm1.TSOnShow(Sender: TObject);
begin
ShowMessage(TTabSheet(sender).Caption);
end;
end.