Forum > General
Creating a TtabSheet and a Tmemo in rutime
(1/1)
BlueIcaro:
Hello, I making some test with lazarus, I want to create a Ttabsheet at runtime, and then add to this new TTabsheet a TMemo.
So I put a TPageControl on a empty form, and a button, so I wrote this:
--- Quote ---
procedure TForm1.Button1Click (Sender: TObject );
Var
ts : Ttabsheet;
memo : tmemo;
begin
ts := ttabsheet.Create(PageControl1);
ts.Name:= 'Test';
ts.PageControl := PageControl1;
ts.Caption:= 'hola';
memo := TMemo.Create(ts);
memo.Name:= 'memo1';
memo.Align:= alclient;
memo.Lines.Add('feo');
end;
--- End quote ---
When I run the program, I click on the button, and I can see the new tabsheet, but Inside of this new TTabsheet I can't see the Tmemo.
What am I doing wrong?
Thanks
/BlueIcaro
felipemdc:
The object inside the Create parameters is not the parent of the control, it is the control responsible for automatically releasing the control, and can be nil too. This should work:
memo := TMemo.Create(ts);
memo.Parent := ts;
memo.Name:= 'memo1';
....
BlueIcaro:
--- Quote from: felipemdc on August 09, 2010, 03:37:01 pm ---The object inside the Create parameters is not the parent of the control, it is the control responsible for automatically releasing the control, and can be nil too. This should work:
memo := TMemo.Create(ts);
memo.Parent := ts;
memo.Name:= 'memo1';
....
--- End quote ---
It's works!! :)
Thank you
/BlueIcaro
Navigation
[0] Message Index