Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi In TListBox keine doppelten Items ! (https://www.delphipraxis.net/36790-tlistbox-keine-doppelten-items.html)

Äfan 25. Dez 2004 22:24


In TListBox keine doppelten Items !
 
Hi,

Ich will das per klick, der Text aus Edit1 in die Liste eingefügt wird. Das geht ! Es ist aber blöd, dass man z.B. den Text "Hallo" öfters einfügen und das soll net sein. Wie mache ich, dass keine Doppelten einträge in die Liste eingefügt werden und eine Meldung gezeigt wird "Gibts schon" ?

mfg

Joe24 25. Dez 2004 22:27

Re: In TListBox keine doppelten Items !
 
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
   if ListBox1.Items.IndexOf( Edit1.Text) = -1 then
     ListBox1.AddItem( Edit1.Text, nil) else
     MessageBox( 0, 'Es werden keine Duplikate akzeptiert!','Hinweis',48);
end;

.Chef 25. Dez 2004 22:31

Re: In TListBox keine doppelten Items !
 
Delphi-Quellcode:
if ListBox.Items.IndexOf(Edit.Text) >= 0 then
Gruß,
Jörg


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:50 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