Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TListBox contains no duplicates

Posted on 1998-10-08
1
Medium Priority
?
259 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 280 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

Technology Partners: 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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Suggested Courses

926 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