From the Delphi help: "Note: Although Lines is implemented as a
TStrings descendant, it does not implement the support for
associating objects with the strings in the list."
If you need to store a single object with the tMemo, not with each
line, then casting the tag should work:
tObject(myMemo.tag) := theObject;
theObject := tObject(myMemo.tag);
I'm not sure what it means to have an object associated with a
line. Say the memo has
"Hello, my name is Delphi."
as a line. The user positions the cursor at "name" and presses
enter. There are now 2 lines. Should the object be cloned? Should
it just go with the first line, and the second line is nil? Or
should it go with the second line, and the first line is nil? I
think this is why objects are not associated with lines.
If you're looking to just display lines of text to the user and want
to have an object associated with a line so (for example) you can do
something when they double-click a particular line, try using
tListBox instead of tMemo.
At 09:38 AM 12/11/2012, John Barrat wrote:
I seems TMemo.lines only supports the String part of a TStrings not the
Objects.
TMemo.Lines.AddObject compiles fine in fact only the string component is
actually loaded.
I need to store an object with this TMemo - how do you recommend I do this?
JohnB
_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list
Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi