这是一个label的动态创建方法 titles:= TLabel.Create(self); titles.Name:='UserTitle_'+inttostr(sqlquery.FieldValues['id']); titles.Parent:=panels; titles.AutoSize:=false; titles.Alignment:=taCenter; titles.Caption:=sqlquery.FieldValues['username']; titles.Width:=panels.width-4; titles.Height:=20; titles.Left:=2; titles.OnClick:=UserClick; titles.Transparent:=true; titles.top:=panels.Height-titles.Height-5; titles.Visible:=true;