Solved

TListBox contains no duplicates

Posted on 1998-10-08
1
255 Views
Last Modified: 2010-04-06
How can I ensure that when I add an Item to a TListBox and/or a TComboBox (e.g. ListBox1.Items.Add('add this')) that the new string is not already in the list?  I am trying to keep duplicates OUT of these lists/components.
0
Comment
Question by:Softtech
1 Comment
 
LVL 7

Accepted Solution

by:
BlackMan earned 70 total points
ID: 1342301
You can do something like this

If ListBox1.Items.IndexOf(MyStr) = -1 Then // MyStr not found
  ListBox1.Items.Add(MyStr);

The same goes for ComboBox..
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question