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!
[Solved] Lazarus - Programmatically created visual component not showing
Delphi, Lazarus, Free Pascal
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2689
Topic starter
September 10, 2013 5:44 AM
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;