Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] Lazarus - Programmatically created visual component not showing

1 Posts
1 Users
0 Likes
1,357 Views
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2689
Topic starter  

I ran into a little snag when I was trying to add visual components to my form at runtime, whatever I would try: the new component would not become visible.

  newLabel := TLabel.Create(Form1);
with newLabel do
begin
Left := 290;
Height := 17;
Top := 35;
Width := 45;
Caption := 'test';
end;   

I wrongfully assumed that the usual Create(Owner) would automatically set the parent property. Well, it doesn't so to make your new component visible you'll have to set the parent manually:

  newLabel := TLabel.Create(Form1);
with newLabel do
begin
Left := 290;
Height := 17;
Top := 35;
Width := 45;
Caption := 'test';
Parent := Form1;
end;   

   
ReplyQuote
Share: