尝试在 TJvFormStorage 中存储 Integer 时出现无效变量操作错误

Invalid variant operation error when trying to store Integer in TJvFormStorage

在 Delphi 10.1.2 的 VCL 应用程序中,我使用 TJvFormStorage 组件来持久存储和恢复数据。

所以在 JvFormStorage1 中,我在设计时创建了一个 StoredValue 来保存 Integer 值:

然后在运行时,我尝试将 Integer 值分配给此 StoredValue:

JvFormStorage1.StoredValue['ToolbarLabelFontSize'].Value := 8;

这会导致无效变体操作错误

但是从上面的截图可以看出,StoredValueValue Type被明确定义为Integer输入!

那么如何为这个 StoredValue 分配一个 Integer 值?

StoredValue[] 属性 提供 access to the variant values directly,因此设置其中一个值的正确方法是:

JvFormStorage1.StoredValue['ToolbarLabelFontSize'] := 8;