i need store a variant value in a TStringList
, so far i try this
var
list : TStringList;
v : OleVariant;
List..AddObject('Item1',v);
or
List..AddObject('Item1',TObject(v));
but in both cases the code not compile because the typecast is invalid or the types are incompatibles.
so the question is, how i can store a variant value in a TStringlist ?
I think the only way would be to wrap your variant in a class and put a reference to that in the object of the stringlist item. You would of course need to take care that the wrapper instances are properly freed when freeing the stringlist. Using the recent Delphi version's that would easily be done by using the "OwnsObjects" parameter of the stringlist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With