delphi判断pagecontrol标签页内是否有stringgrid组件
1个回答
展开全部
没错啊
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var Label1:TLabel;
Edit1:TEdit;
Button1:TButton;
Memo1:TMemo;
begin
Label1:=TLabel.Create(Self);
Label1.Caption:= 'Label1 ';
Label1.Left:=10;
Label1.Top:=10;
Label1.Parent:=TabSheet1;
ShowMessage(IntToStr(PageControl1.ActivePage.ControlCount));
Edit1:=TEdit.Create(Self);
Edit1.Text:= 'Edit1 ';
Edit1.Left:=10;
Edit1.Top:=25;
Edit1.Parent:=TabSheet1;
ShowMessage(IntToStr(PageControl1.ActivePage.ControlCount));
Button1:=TButton.Create(Self);
Button1.Caption:= 'Button1 ';
Button1.Left:=10;
Button1.Top:=45;
Button1.Parent:=TabSheet1;
ShowMessage(IntToStr(PageControl1.ActivePage.ControlCount));
Memo1:=TMemo.Create(Self);
Memo1.Text:= 'Memo1 ';
Memo1.Left:=10;
Memo1.Top:=70;
Memo1.Parent:=TabSheet1;
ShowMessage(IntToStr(PageControl1.ActivePage.ControlCount));
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls;
type
TForm1 = class(TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var Label1:TLabel;
Edit1:TEdit;
Button1:TButton;
Memo1:TMemo;
begin
Label1:=TLabel.Create(Self);
Label1.Caption:= 'Label1 ';
Label1.Left:=10;
Label1.Top:=10;
Label1.Parent:=TabSheet1;
ShowMessage(IntToStr(PageControl1.ActivePage.ControlCount));
Edit1:=TEdit.Create(Self);
Edit1.Text:= 'Edit1 ';
Edit1.Left:=10;
Edit1.Top:=25;
Edit1.Parent:=TabSheet1;
ShowMessage(IntToStr(PageControl1.ActivePage.ControlCount));
Button1:=TButton.Create(Self);
Button1.Caption:= 'Button1 ';
Button1.Left:=10;
Button1.Top:=45;
Button1.Parent:=TabSheet1;
ShowMessage(IntToStr(PageControl1.ActivePage.ControlCount));
Memo1:=TMemo.Create(Self);
Memo1.Text:= 'Memo1 ';
Memo1.Left:=10;
Memo1.Top:=70;
Memo1.Parent:=TabSheet1;
ShowMessage(IntToStr(PageControl1.ActivePage.ControlCount));
end;
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询