I wrote this code:
TButton.Create(self).Name := 'Button1';
with TButton(FindComponent('Button1')) do
begin
top := 88;
left := 88;
height := 88;
width := 88;
Parent := somepanel;
end;
It works fine. It shows my newly created Button1.
But when I do the following:
TButton.Create(self).Name := 'Button1';
with TButton(FindComponent('Button1')) do
begin
top := 88;
left := 88;
height := 88;
width := 88;
Parent := TPanel(Findcomponent('somepanel'));
end;
which was supposed to be exactly the same, my button isn't showed. WHY?
I NEED the FindComponent thing because I somepanel to be a panel that is created runtime, but it seems like I can't get a component build at runtime to be a parent and show the components on it, or has it something to do with the FindComponent method? Because as you see, even though somepanel was created at design time, it won't show my button on it, if it's child has called its parent TPanel(Findcomponent('somepanel')) instead of somepanel.
How do I solve this?
I tried with BringToFront, it worked for some reason yesterday but today it doesn't... this is really strange. Please, help me!
TButton.Create(self).Name := 'Button1';
with TButton(FindComponent('Button1')) do
begin
top := 88;
left := 88;
height := 88;
width := 88;
Parent := somepanel;
end;
It works fine. It shows my newly created Button1.
But when I do the following:
TButton.Create(self).Name := 'Button1';
with TButton(FindComponent('Button1')) do
begin
top := 88;
left := 88;
height := 88;
width := 88;
Parent := TPanel(Findcomponent('somepanel'));
end;
which was supposed to be exactly the same, my button isn't showed. WHY?
I NEED the FindComponent thing because I somepanel to be a panel that is created runtime, but it seems like I can't get a component build at runtime to be a parent and show the components on it, or has it something to do with the FindComponent method? Because as you see, even though somepanel was created at design time, it won't show my button on it, if it's child has called its parent TPanel(Findcomponent('somepanel')) instead of somepanel.
How do I solve this?
I tried with BringToFront, it worked for some reason yesterday but today it doesn't... this is really strange. Please, help me!