In Delphi Prism, I need to assign objectcollection from ListBox to an ArrayList in a single statement. So far I have not found any solution.
In Delphi, this is how I did it.
theUser.Groups.Assign(ListBox1.Items);
Groups is a TList in Delphi and ArrayList in Delphi Prism. When I tried to do the same in delphi prism, it gives me the following errors.
“Groups.TGroupList” does not contain a definition for “Assign” in expression “theUser.groups.Assign”
If ArrayList doesn’t have method that accepts objectcollection, then I will have to loop through each objects in the ListBox items and add it to ArrayList.
How would you do it?
Thanks in advance.
You should use the
AddRange()method ofArrayList.The equivalent to your Delphi code is: