1 在一个form1中,有一个page control,可以动态生成tabsheet
2 动态生成form2 ,放置在tabsheet上
3 在form2 中的show事件,可以改变控件的visible
问题:控件的visible=false ,控件可以看见。form1源码:unit FormPageForm;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin;type
TForm1 = class(TForm)
ToolBar1: TToolBar;
btnPage: TToolButton;
PageControl1: TPageControl;
procedure btnPageClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}uses
FormInPage;procedure TForm1.btnPageClick(Sender: TObject);
var
Form: TForm;
Sheet: TTabSheet;
begin
// create a tabsheet within the page control
Sheet := TTabSheet.Create(PageControl1);
Sheet.PageControl := PageControl1;
// create the form and place it in the tabsheet
Form := TForm2.Create (Application);
Form.BorderStyle := bsNone;
Form.Align := alClient;
Form.Parent := Sheet;
Form. Visible := True;
// activate and set title
PageControl1.ActivePage := Sheet;
Sheet.Caption := Form.Caption;
end;end.
form2源码:
unit FormInPage;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm2 = class(TForm)
RichEdit1: TRichEdit;
Edit1: TEdit;
Label1: TLabel;
Edit2: TEdit;
Label2: TLabel;
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form2: TForm2;implementation{$R *.dfm}procedure TForm2.FormShow(Sender: TObject);
begin
Edit1.Visible:=False;
Label1.Visible :=False;
Edit2.Visible:=True;
Label2.Visible :=True; Self.Repaint;end;end.
------------------------------
[?]忘各位能帮助解决,谢谢!
2 动态生成form2 ,放置在tabsheet上
3 在form2 中的show事件,可以改变控件的visible
问题:控件的visible=false ,控件可以看见。form1源码:unit FormPageForm;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin;type
TForm1 = class(TForm)
ToolBar1: TToolBar;
btnPage: TToolButton;
PageControl1: TPageControl;
procedure btnPageClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}uses
FormInPage;procedure TForm1.btnPageClick(Sender: TObject);
var
Form: TForm;
Sheet: TTabSheet;
begin
// create a tabsheet within the page control
Sheet := TTabSheet.Create(PageControl1);
Sheet.PageControl := PageControl1;
// create the form and place it in the tabsheet
Form := TForm2.Create (Application);
Form.BorderStyle := bsNone;
Form.Align := alClient;
Form.Parent := Sheet;
Form. Visible := True;
// activate and set title
PageControl1.ActivePage := Sheet;
Sheet.Caption := Form.Caption;
end;end.
form2源码:
unit FormInPage;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;type
TForm2 = class(TForm)
RichEdit1: TRichEdit;
Edit1: TEdit;
Label1: TLabel;
Edit2: TEdit;
Label2: TLabel;
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form2: TForm2;implementation{$R *.dfm}procedure TForm2.FormShow(Sender: TObject);
begin
Edit1.Visible:=False;
Label1.Visible :=False;
Edit2.Visible:=True;
Label2.Visible :=True; Self.Repaint;end;end.
------------------------------
[?]忘各位能帮助解决,谢谢!
其实属性值已经设置成功了,只是显示的问题了
Form.ManualDock(PageControl1, nil, alClient);
Form.Visible := True; 这句完全等同于 Form.Show这样作完后
Sheet.Caption = Form.Caption 代码激活某叶可以用这个