我读到了这个问题,其中讨论了相同的问题。无论如何,我能够在 Delphi 2009 中做到这一点,在升级到 XE 后就不可能了。
我在这里粘贴一个简单虚拟的示例:这可以编译 2009 并在 XE 上给出 E2064...为什么?有没有可能设置 XE 的行为方式像 2009 一样?还是应该采用一种解决方法?
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TTestRecord = record
FirstItem : Integer;
SecondItem : Integer;
end;
TForm2 = class(TForm)
procedure AssignValues;
private
FTestRecord :TTestRecord;
public
property TestRecord : TTestRecord read FTestRecord write FTestRecord;
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.AssignValues;
begin
with TestRecord do
begin
FirstItem := 14; // this gives error in XE but not in 2009
SecondItem := 15;
end;
end;
end.