I'm actually a little embarrased I have to ask this question. Seems simple enought to accomplish, but I seem to be having a brain fart. I've even searched tek-tips and can't find a solution...
I dynamically create 10 labels on a panel at runtime. At some point I need to remove (free) those labels from that panel at runtime also.
So, I was trying to loop though the components on the on the panel and free the component if it is a TLabel. No go.
Below is my code:
try
for x := 0 to (panel1.ComponentCount -1) do begin
if (panel.Components[x] is TLabel) then
TLabel(panel1.components[x]).free;
end;
finally
panel1.Repaint;
end;
I'm sure there is a better way to accomplish this simple task, especially since the above doesn't work anyway.
Thanks..
I dynamically create 10 labels on a panel at runtime. At some point I need to remove (free) those labels from that panel at runtime also.
So, I was trying to loop though the components on the on the panel and free the component if it is a TLabel. No go.
Below is my code:
try
for x := 0 to (panel1.ComponentCount -1) do begin
if (panel.Components[x] is TLabel) then
TLabel(panel1.components[x]).free;
end;
finally
panel1.Repaint;
end;
I'm sure there is a better way to accomplish this simple task, especially since the above doesn't work anyway.
Thanks..