A Delphi Custom Control: A TRichEdit with a TLabel Above It
- by doubleu
Hello,
I want to create an custom control (descendant of TRichEdit).
I simply want add some text above the editfield.
I've created my own control and I override the constructor to create a TLabel for the caption.
It works, but my problem: How is it possible to move the label above the richedit?
When I set Top := -5 the label begins to disappaer.
Here's the code of the constructor:
constructor TDBRichEditExt.Create(AOwner: TComponent);
begin
inherited;
lblCaption := TLabel.Create(self);
lblCaption.Parent := parent;
lblCaption.Caption := 'Header';
lblCaption.Top := -5;
end;
I think it's logic that the label disappaers since the richedit is the parent.
I've tried
lblCaption.Parent := self.parent;
To make the form which owns the richedit the parent - but this dosn't work...
How could I achieve this?
Thank you all!