【发布时间】:2012-11-09 04:36:26
【问题描述】:
如何删除创建的标签。我试过FindComponent 但失败了,我该怎么办?我应该在那里设置其他组件的父组件,如 TPanel 还是什么?
procedure TForm1.Button1Click(Sender: TObject);
var
lblLink: TLabel;
begin
for i := 0 to stringtList.Count-1 do
begin
lblLink := TLabel.create(self);
with lblLink do
begin
name:='lblLink'+inttostr(i);
caption:inttostr(i);
Parent := self;
font.style := [fsUnderline];
cursor := crHandPoint;
color := clBlue;
font.Color := clBlue;
end;
end;
end;
【问题讨论】:
-
我认为 FindComponent 没有理由找不到您的标签,您是否传递了像“lblLink0”这样的名称?
-
是的,但这是个坏主意!因为标签的数量取决于
stringtList的数量,它肯定是不稳定的