Discussion:
[Lazarus] Combobox with sorted list of unique items?
Bo Berglund via Lazarus
2018-10-12 11:21:56 UTC
Permalink
I am trying to use a combobox as a container for recently used IP
addresses for easy selection by the user.
I can set the combobox style to csDropDown and Sorted to true.
But I cannot find the duplicates setting so I can set it to unique...

Is there some other way to do this except by loading the data on
startup into a TStringList with sorted and unique set and then
transfer the content into the Combobox?


--
Bo Berglund
Developer in Sweden

--
Vojtěch Čihák via Lazarus
2018-10-12 12:30:21 UTC
Permalink
I just tried TStringList(ComboBox1.Items).Duplicates:=dupIgnore; but it does not work for combo (in Qt4).
 
V.
______________________________________________________________
> Od: "Bo Berglund via Lazarus" <***@lists.lazarus-ide.org>
> Komu: ***@lists.lazarus.freepascal.org
> Datum: 12.10.2018 13:22
> Předmět: [Lazarus] Combobox with sorted list of unique items?
>
I am trying to use a combobox as a container for recently used IP
addresses for easy selection by the user.
I can set the combobox style to csDropDown and Sorted to true.
But I cannot find the duplicates setting so I can set it to unique...

Is there some other way to do this except by loading the data on
startup into a TStringList with sorted and unique set and then
transfer the content into the Combobox?


--
Bo Berglund
Developer in Sweden

--
_______________________________________________
Lazarus mailing list
***@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus <https://lists.lazarus-ide.org/listinfo/lazarus>
Bart via Lazarus
2018-10-12 13:30:52 UTC
Permalink
On Fri, Oct 12, 2018 at 2:30 PM Vojtěch Čihák via Lazarus
<***@lists.lazarus-ide.org> wrote:
>
> I just tried TStringList(ComboBox1.Items).Duplicates:=dupIgnore; but it does not work for combo (in Qt4).

Override Insert and check if it is already in there?

Bart
--
Bo Berglund via Lazarus
2018-10-12 15:01:07 UTC
Permalink
On Fri, 12 Oct 2018 15:30:52 +0200, Bart via Lazarus
<***@lists.lazarus-ide.org> wrote:

>On Fri, Oct 12, 2018 at 2:30 PM Vojt?ch ?ihák via Lazarus
><***@lists.lazarus-ide.org> wrote:
>>
>> I just tried TStringList(ComboBox1.Items).Duplicates:=dupIgnore; but it does not work for combo (in Qt4).
>
>Override Insert and check if it is already in there?
>
It is going to be simpler to just use a TStringList container while
reading from the ini file because it can be set for sorted and
dupignore.
Then at the end just assign the stringlist to the combobox text
property.

combobox.items.text := stringlist.text;


--
Bo Berglund
Developer in Sweden

--
Bart via Lazarus
2018-10-13 14:15:47 UTC
Permalink
On Fri, Oct 12, 2018 at 5:01 PM Bo Berglund via Lazarus
<***@lists.lazarus-ide.org> wrote:

> combobox.items.text := stringlist.text;

combobox.items.assign(stringlist)?

--
Bart
--
Loading...