delphivariantdelphi-10.1-berlinjvcl

Invalid variant operation error when trying to store Integer in TJvFormStorage


In a VCL application in Delphi 10.1.2, I use a TJvFormStorage component to persistently store and restore data.

So in JvFormStorage1 at design-time I have created a StoredValue to hold an Integer value:

enter image description here

Then at runtime, I try to assign an Integer value to this StoredValue:

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

This causes an Invalid variant operation error!

But as you can see from the screenshot above, the Value Type of the StoredValue is explicitly defined as Integer type!

So how can I assign an Integer value to this StoredValue?


Solution

  • The StoredValue[] property provides access to the variant values directly, so the correct way to set the value of one of these values would be:

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