I have created a frame which comprises a panel on which are mounted 2 other
panels and a drop down combo box. (The combobox and 2 child frames are
arranged horizontally in line so that the whole item appears as a single
line)
My plan was to create an instance of this frame at run time for each line I
read from a file , set the Caption property of the child panels and add a
number of items to the combo. I have exposed the frame's sub components as
properties and set each subcomponent to true.
The only way I have managed to create a set of these frames at run time is
during the main form's create process. Even then I cannot seem to be able to
access these frames or their sub-components.
This is my main program code
unit PICFuseConfigurator;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, PICFuseItem;
type
TfmFuseConfig = class(TForm)
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure FormPaint(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure AddFuseItem(pIndex: Integer);
end;
var
fmFuseConfig: TfmFuseConfig;
FuseList: TFrame;
implementation
{$R *.dfm}
procedure TfmFuseConfig.FormCreate(Sender: TObject);
Var i: Integer;
begin
//
for i := 0 to 8 do
begin
AddFuseItem(i);
end;
end;
procedure TfmFuseConfig.AddFuseItem(pIndex: Integer);
begin
FuseList := TFrmFuse.Create(Self);
with FuseList do
begin
Parent := fmFuseConfig;
Visible := True;
Name := 'FuseList' + IntToStr(pIndex);
Align := alTop;
end;
end;
end.
This is my Frame's code
unit PICFuseItem;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TfrmFuse = class(TFrame)
pnlFuseEntry: TPanel;
cmbValue: TComboBox;
pnlName: TPanel;
pnlDescription: TPanel;
private
{ Private declarations }
public
{ Public declarations }
Constructor Create(AOwner: TComponent);
Published
property ItemName: TPanel Read pnlName Write pnlName;
property ItemValues: TComboBox Read cmbValue Write cmbValue;
property ItemDesc: TPanel Read pnlDescription Write pnlDescription;
end;
implementation
{$R *.dfm}
Constructor TfrmFuse.Create(AOwner: TComponent);
begin
inherited;
pnlName.SetSubComponent(True);
cmbValue.SetSubComponent(True);
pnlDescription.SetSubComponent(True);
end;
end.
Is it possible to build up arrays of controls in Delphi or am I trying to do
something inherantly impossible.
JohnB
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi