faqts : Computers : Programming : Languages : Delphi

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

4 of 4 people (100%) answered Yes
Recently 4 of 4 people (100%) answered Yes

Entry

Delphi: Component: PageControl: How to create dynamically a PageControl component with 2 tabsheets?

Apr 4th, 2006 16:38
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 04 April 2006 - 11:49 pm ----------------------

Delphi: Component: PageControl: How to create dynamically a 
PageControl component with 2 tabsheets?

===

Steps: Overview:

 1. -E.g. using the program:

--- cut here: begin --------------------------------------------------

procedure TForm1.Button1Click(Sender: TObject);
var PageControl1: TPageControl;
var TabSheet1: TTabSheet;
var TabSheet2: TTabSheet;
begin
  PageControl1 := TPageControl.Create( Self );
  PageControl1.Parent := Self;
  //
  TabSheet1 := TTabSheet.Create( Self );
  TabSheet1.Caption := 'TabSheet1';
  TabSheet1.PageControl := PageControl1;
  //
  TabSheet2 := TTabSheet.Create( Self );
  TabSheet2.Caption := 'TabSheet2';
  TabSheet2.PageControl := PageControl1;
end;

--- cut here: end ----------------------------------------------------

 2. -All together:

--- cut here: begin --------------------------------------------------

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, 
Forms,
  Dialogs, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    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 PageControl1: TPageControl;
var TabSheet1: TTabSheet;
var TabSheet2: TTabSheet;
begin
  PageControl1 := TPageControl.Create( Self );
  PageControl1.Parent := Self;
  //
  TabSheet1 := TTabSheet.Create( Self );
  TabSheet1.Caption := 'TabSheet1';
  TabSheet1.PageControl := PageControl1;
  //
  TabSheet2 := TTabSheet.Create( Self );
  TabSheet2.Caption := 'TabSheet2';
  TabSheet2.PageControl := PageControl1;
end;

end.

--- cut here: end ----------------------------------------------------

===

Internet: see also:

---



----------------------------------------------------------------------