> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Ross Levis
> Sent: Friday, 6 July 2001 12:22
> To: Multiple recipients of list delphi
> Subject: Listbox items (Was: Re: [DUG]: array of TStringList)
>
>
> Thanks all for the help. I think I will use a static array and limit the
> numbers.
>
> I have another newbie question. What is the standard way of
> internally storing
> data attached to a listbox item.
> ie. I have a listbox which has user defined items that can be
> added & deleted.
> For each of the items I need to display/store particular information.
> eg. On the left I have a Listbox containing account numbers and
> on the right I
> have edit boxes containing Name, Address etc.
>
> Can I use the Items.Objects property to link each item to another
> object in
> this case? Or do I simply store the Name/Address data in a string array
> indexed on the ItemIndex. That creates a problem when the user
> deletes an item
> from the list -- I would have to move the data around in the array which I
> would rather not do. Maybe I should use the item Tag property to
> store the
> index of the related array data.
>
> (BTW: The data will eventually be saved to a text file)
You can link to another object.
In one of my applications I needed to store an integer. I defined a type
PLongInt as a pointer to a LongInt.
In the code I then created a new instance of the type assigning it to a
local variable, set its value to the number and then assigned it to the Data
property of the TListView. That's a little different but not much.
All you need to do is:
* Create a new instance of an object with a local variable
* Assign that instance to the Objects property that corresponds to the list
item. Since everything descends from TObject it is a simple assignation.
* When you retrieve the object you will need to typecast it to the original
object type otherwise you will not be able to access any properties or
methods other than those in TObject.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"