BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Writing component with subcomponents

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design
View previous topic :: View next topic  
Author Message
diogoap82
Guest





PostPosted: Sun Aug 27, 2006 11:40 pm    Post subject: Writing component with subcomponents Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi OO design All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.