delphi - Convert strings in ListBox to List<String> -


tlistbox component contains set of rows (strings). how can set list tlist ? code examples below, not give desired result. (Сode not compile)

mylist  := tlist<string>.create(mylistbox); mylist  := tlist<string>.create(mylistbox.items); mylist  := tlist<string>.create(mylistbox.items.tostringarray); 

is possible without using loop or not? thanks!

you can this:

mylist := tlist<string>.create; try   mylist.addrange(mylistbox.items.tostringarray);   ....   mylist.free; end; 

if wanted assign items in constructor you'd need instance of tenumerable<string>. that's not easy graft on tstrings outside. think above code cleanest.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -