Posts: 105
Threads: 33
Joined: Jun 2019
Reputation:
0
Location: Canada
I am using Intraweb 15.2.69 with Rad Studio 10.2.3
How to get all the values or text selected in a TIWListBox when MultiSelect option is true?
Because TIWListBox->SelectedValue and TIWListBox->SelectedText are both UnicodeString instead of TStringList!
So only one value is returned instead of a list even when multiple values are selected at the same time!
Posts: 105
Threads: 33
Joined: Jun 2019
Reputation:
0
Location: Canada
I am supposed to be a priority user!
Why I have no response up to today?
Posts: 2,261
Threads: 196
Joined: Mar 2018
Reputation:
86
Location: Auckland, New Zealand
We are going to extend the TIWCustomListCombo.GetSelectedValue and GetSelectedText to include all elements in a single string (comma delimited) as it works with the TIWSelect control. This modification will be included in the next update
Posts: 105
Threads: 33
Joined: Jun 2019
Reputation:
0
Location: Canada
Thanks
But why not to have the TIWListBox return a TStringList instead of a UnicodeString?
A TStringList will make it easier to retrieve the values.
At the contrary of a UnicodeString for which I will need to write a code to separate the values from the commas.
Posts: 105
Threads: 33
Joined: Jun 2019
Reputation:
0
Location: Canada
I know!
I just wanted to avoid to manipulate this kind of staffs like additional variables, pointers specially when working with threads!
If the TStringList is a property of the component, it automatically goes with it!
Posts: 2,261
Threads: 196
Joined: Mar 2018
Reputation:
86
Location: Auckland, New Zealand
04-07-2023, 08:52 PM
(This post was last modified: 04-07-2023, 08:53 PM by Alexandre Machado.)
If I create a TStringList inside the method and return a instance to the calling code you will also have to deal with its destruction and call it inside a try..finally block which is basically an anti-pattern considering this specific scenario.
It is a much better and clean code if the calling code creates the TStringList and takes care of its destruction.
Posts: 2,261
Threads: 196
Joined: Mar 2018
Reputation:
86
Location: Auckland, New Zealand
If comma is in the items, that item will be enclosed in double quotes. Something like what TStringList does