 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
diogoap82 Guest
|
Posted: Sun Aug 27, 2006 11:40 pm Post subject: Writing component with subcomponents |
|
|
Hi,
I'm writing a Delphi win32 component, it will be a component to edit
objects, I will link a TObjecList into it and it will show the objects
in a grid. It also will have some buttons, for insert, edit and delete
operations.
The component inherits from TCustomPanel and on "Create" method another
controls (panel, buttons and grid) are created.
Its structure is something thus:
TObjectEdit = class(TCustomPanel)
private
FpanlGridTittleInfo: TCustomPanel;
FpanlGridTittleButtons: TCustomPanel;
FbtbtDelete: TButton;
FbtbtEdit: TButton;
FbtbtInsert: TButton;
FDetailGrid: TGrid;
FDetailObjectList: TObjectList;
function GetDetailObjectList: TObjectList;
procedure SetDetailObjectList(const Value: TObjectList);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property DetailObjectList: TObjectList read GetDetailObjectList write
SetDetailObjectList;
end;
In the constructor of TObjectEdit I create all subcomponents:
constructor TObjectEdit.Create(AOwner: TComponent);
begin
FbtbtDelete:= TButton.Create(Self);
FbtbtEdit:= TButton.Create(Self);
... //Creating another components
FDetailGrid:= TGrid.Create(AOwner);
FDetailGrid.Parent:= Self;
FDetailGrid.Name:= 'grDetail';
FDetailGrid.Align:= alClient;
end;
Grid is created with AOwner property because I need to store your
properties on the dfm, but when I paste a component on the form and use
it, the error "A component named grDetail already exists" occurs.
How I would solve this problem?
Thanks.
Diogo Augusto Pereira |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|