在以上的问题“左边不能被分配到”在德尔福记录类型的属性,有一个答案椿Krijthe演示如何分配至创纪录的财产的字段可以由记录的声明中使用特性来完成。为便于参考,以下是Toon Krijthe发布的代码段。
type
TRec = record
private
FA : integer;
FB : string;
procedure SetA(const Value: Integer);
procedure SetB(const Value: string);
public
property A: Integer read FA write SetA;
property B: string read FB write SetB;
end;
procedure TRec.SetA(const Value: Integer);
begin
FA := Value;
end;
procedure TRec.SetB(const Value: string);
begin
FB := Value;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
FRec : TRec;
public
property Rec : TRec read FRec write FRec; …Run Code Online (Sandbox Code Playgroud)