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)

Thanks,
Ross.

Sergei Stenkov wrote:

> Hello all
>
> Ross,
>
> Just 2c of mine:
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> var
>   i : Integer;
>   aList: Array of TStringList;
> begin
>   try
>     for i := 0 to xxxxxx do begin
>       SetLength(aList, i + 1);
>       aList[i] := TStringList.Create;
>     end;
>
>     // do your what you need
>   finally
>     if Length(aList) > 0 then
>       for i := Low(aList) to High(aList) do
>         if aList[i] <> nil then
>           // Clean up the objects
>           aList[i].Free;
>       Finalize(aList); //Uninitializes a dynamically allocated variable
>   end;
> end;
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Best regards,
> Sergei Stenkov
>
> > I was hoping the following would work but it appears not.  It compiles
> > OK but produces memory errors at runtime.  Why doesn't the compiler
> > complain if TSringList can't be used in an array?
> >
> > var
> >   Categories : array of TStringList;
> > begin
> >   Categories[0] := TStringList.Create;
> > end;
> >
> > Cheers,
> > Ross.
>
> ---------------------------------------------------------------------------
>     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"

---------------------------------------------------------------------------
    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"

Reply via email to