Re: Copy TStringList to TListBox
- From: "alanglloyd@xxxxxxx" <alanglloyd@xxxxxxx>
- Date: Fri, 3 Oct 2008 03:19:13 -0700 (PDT)
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.
Hence you can free the TStringList object (itself not its Objects
array) you have Assign(ed) to the listbox, and the listbox still
maintains the original pointers (TObject references) which were in the
TStringList.Objects.
StringList1.Clear; //this changes >=1 objects in ListBox1!
Not in my experience (D3)
.... or have I misunderstood you.
Alan Lloyd
.
- Follow-Ups:
- Re: Copy TStringList to TListBox
- From: Arjan
- Re: Copy TStringList to TListBox
- References:
- Copy TStringList to TListBox
- From: Arjan
- Copy TStringList to TListBox
- Prev by Date: Re: Copy TStringList to TListBox
- Next by Date: Re: Copy TStringList to TListBox
- Previous by thread: Re: Copy TStringList to TListBox
- Next by thread: Re: Copy TStringList to TListBox
- Index(es):
Relevant Pages
|