Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi String in ListBox einfügen ohne Duplikate ? (https://www.delphipraxis.net/122793-string-listbox-einfuegen-ohne-duplikate.html)

thomas2009 22. Okt 2008 00:23


String in ListBox einfügen ohne Duplikate ?
 
Hallo

ich möchte Strings in ListBox einfügen. Es soll aber keine Duplikate
Ich muss zuerst nach dem String in ListBox suchen und wenn das Ergebnis = 0 then
Delphi-Quellcode:
ListBox1.Items.Add('string')
else
ListBox1.Items.Add('string'+IntToStr(1)); // einen anderen namen

alleinherrscher 22. Okt 2008 00:33

Re: String in ListBox einfügen ohne Duplikate ?
 
Guck dir mal Listbox.items.indexof(aString) an.

Ich würde das so machen

Delphi-Quellcode:

If Listbox.items.indexof(Teststring) < 0 then   //teststring ist nicht in Listbox
   //mache irgendetwas
else                                            //teststring ist in Listbox
   //mache etwas anderes


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:25 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz