问题
动态创建的VCL控件如何改变属性?例如
procedure StartForm.ShowLabel(Top,Left,Width,Height: Integer;
Caption,Name: String;Parent: TForm;Color,FontColor: TColor);
var
LoadLabel: TLabel;
begin
LoadLabel := TLabel.Create(Parent);
LoadLabel.Parent := Parent;
LoadLabel.AutoSize := False;
LoadLabel.Caption := Caption;
LoadLabel.Name := Name;
LoadLabel.Top := Top;
LoadLabel.Left := Left;
LoadLabel.Width := Width;
LoadLabel.Height := Height;
LoadLabel.Color := Color;
LoadLabel.Font.Color := FontColor;
//LoadLabel.Font.Size := 1;
//LoadLabel.Transparent := True;
end;现在我想改变LoadLabel的Width属性,如何进行更改?
动态创建的VCL控件如何改变属性?例如
procedure StartForm.ShowLabel(Top,Left,Width,Height: Integer;
Caption,Name: String;Parent: TForm;Color,FontColor: TColor);
var
LoadLabel: TLabel;
begin
LoadLabel := TLabel.Create(Parent);
LoadLabel.Parent := Parent;
LoadLabel.AutoSize := False;
LoadLabel.Caption := Caption;
LoadLabel.Name := Name;
LoadLabel.Top := Top;
LoadLabel.Left := Left;
LoadLabel.Width := Width;
LoadLabel.Height := Height;
LoadLabel.Color := Color;
LoadLabel.Font.Color := FontColor;
//LoadLabel.Font.Size := 1;
//LoadLabel.Transparent := True;
end;现在我想改变LoadLabel的Width属性,如何进行更改?
LoadLabel := TLabel.Create(self);
LoadLabel.Parent := self;
想在函数已经创建后
再修改他的属性
如调用:ShowLabel(100,100,100,10,'a','b',ShowForm,clBlue,clBlue);
会在ShowForm上加一个离Form Top,Left分别为100,宽为100,高为10,名字为'b'...等的Label组件
现在我现想再改Width为150怎么改?
var tempLabel:TLabel;
begin
tempLabel:=TLabel.Create(self);
tempLabel.Parent:=Self;
tempLabel.Caption:='haha';
tempLabel.Name:='aa';
tempLabel.Left:=100;
tempLabel.Top:=100;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
(self.FindComponent('aa') as TLabel).Caption:='xixi';
end;