【发布时间】:2017-05-10 08:16:36
【问题描述】:
我在 Fire-monkey 中创建了一个组件,并在其中创建了一个 TEdit。 我的组件有一个名为 Value 的字符串属性,通过向它添加任何字符串,我的组件将在 Tedit 中显示它。 在设计时,一切正常。但在运行时,Tedit 中没有显示任何内容 我的代码是
type
TMyComponent = class(TPanel)
private
{ Private declarations }
Edit:TEdit;
FValue:String;
Procedure SetValue(Const Value:String);
protected
{ Protected declarations }
Constructor Create(Aoner:TComponent); Override;
Destructor Destroy; Override;
public
{ Public declarations }
published
{ Published declarations }
Property Value:String Read FValue Write SetValue;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TMyComponent]);
end;
Constructor TMyComponent.Create(Aoner:TComponent);
begin
Inherited;
Width:=100;
Height:=100;
Edit:=TEdit.Create(Self);
Edit.Parent:=Self;
Edit.Width:=30;
Edit.Text:='';
Edit.Align:=TAlignLayout.Scale;
end;
Procedure TMyComponent.SetValue(const Value: string);
begin
FValue:=Value;
Edit.Text:=FValue;
end;
Destructor TMyComponent.Destroy;
begin
Edit.Destroy;
Inherited Destroy;
end;
end.
我该怎么办?
【问题讨论】:
-
您在运行时测试的代码在哪里?
-
看加载的
-
我无法重现您在运行时遇到的任何问题。请尝试通过更好的解释来改进您的问题,并将任何缺失的代码添加到您的问题中。
-
我认为运行时他的意思是,如果您将此组件和按钮放在表单上并在按钮单击事件中写入
MyComponent1.Value := 'test'组件中的值不会改变。
标签: delphi firemonkey custom-component