Re: Copy TStringList to TListBox
- From: Arjan <arjan@xxxxxxxxxxxxxxx>
- Date: Fri, 03 Oct 2008 22:10:43 +0100
In message <78b1374c-a641-42f9-8192-65a07761daaa@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
"alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx> wrote:
On 2 Oct, 23:39, Arjan <ar...@xxxxxxxxxxxxxxx> wrote:
Hello all,
I have a TStringList containing some strings, with associated objects.
I wish to copy this list to a TListBox, so that the Listbox contains
a separate copy of the Stringlist items (including the objects).
I use Assign, but it seems that this only assigns pointers to the original
objects in the Stringlist instead of copying them to new objects:
Not quite. Assign copies the values which are in the
TStringList.Objects array.
These are normally pointers to objects (ie a TObject refererence) but
can be any 4-byte value typecast to a TObject.
[snip]
StringList1.Clear; //this changes >=1 objects in ListBox1!
Not in my experience (D3)
.. or have I misunderstood you.
No, my mistake.
I had made a TStringList descendant with a new Clear (overriding the
original) which Frees all the objects, then calls the original Clear. Sorry,
I was confused.
Thanks everyone.
Now I know that Assign only copies pointers, I have mended my code.
Everything works!
Regards,
Arjan
.
- References:
- Copy TStringList to TListBox
- From: Arjan
- Re: Copy TStringList to TListBox
- From: alanglloyd@xxxxxxx
- Copy TStringList to TListBox
- Prev by Date: Re: Copy TStringList to TListBox
- Next by Date: Remove dotted indication in Tlistbox
- Previous by thread: Re: Copy TStringList to TListBox
- Next by thread: Remove dotted indication in Tlistbox
- Index(es):
Relevant Pages
|