Entry
Delphi: Component: PageControl: How to create dynamically a PageControl component with N tabsheets?
Apr 4th, 2006 16:45
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 04 April 2021 - 11:52 pm ----------------------
Delphi: Component: PageControl: How to create dynamically a
PageControl component with N tabsheets?
---
1. -Create a new application
1. -Open a form
1. -Put a button on it
2. -E.g. using the program:
--- 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);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var PageControl1: TPageControl;
var TabSheet: array [1..10] of TTabSheet;
var I : integer;
var minI : integer;
var maxI : integer;
begin
minI := 1;
maxI := 10;
PageControl1 := TPageControl.Create( Self );
PageControl1.Parent := Self;
for I := minI to maxI do
begin
TabSheet[ I ] := TTabSheet.Create( Self );
TabSheet[ I ].Parent := Self;
TabSheet[ I ].PageControl := PageControl1;
end;
end;
end.
--- cut here: end ----------------------------------------------------
3. -Run the program
4. -Click the button
1. -In this case 10 tabsheets will be created dynamically
===
Tested successfully on
Microsoft Windows XP Professional (service pack 2),
running
Delphi v7.x
===
Internet: see also:
---
----------------------------------------------------------------------