我不想保存在 DFM 文件中的自定义组件上有一个属性。我已经重写了 DefineProperties 方法以不提供 ReadData 和 WriteData 过程,期望它不会保存它的值,但它仍然可以。
procedure TAEFDQuery.DefineProperties(Filer: TFiler);
begin
inherited;
// Set the ADO Compatibility custom properties to not be saved on the DFM
Filer.DefineProperty('CommandText', nil, nil, False);
end;
不保存此属性的原因是因为我已经将一个项目从 ADO 移植到 FireDAC,并且我创建了“假”属性,允许某些 ADO 代码原样运行,并将其重定向到其对应的 FireDAC 属性。
type
TAEFDQuery = class(TFDQuery)
private
function GetCommandText: string;
procedure SetCommandText(AValue: string);
protected
procedure DefineProperties(Filer: TFiler); override;
published
property CommandText: integer read GetCommandText write SetCommandText;
end;
implementation
procedure TAEFDQuery.SetCommandText(AValue: string);
begin
SQL.Text := AValue;
end;
function TAEFDQuery.GetCommandText: string;
begin
Result := SQL.Text;
end;
procedure TAEFDQuery.DefineProperties(Filer: TFiler);
begin
inherited;
// Set the ADO Compatibility custom properties to not be saved on the DFM
Filer.DefineProperty('CommandText', nil, nil, False);
end;
为了兼容性起见,保留这些“假”属性的正确方法是如何不让它们用无用的真实属性副本填充 DFM 文件?
谢谢你。