Autor Beitrag
webmaker
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 205



BeitragVerfasst: Mo 27.01.03 20:54 
Hallo
ich habe Frage zu einer listbox und zwar will ich, dass alle Items außer die die mit line beginnen gelöscht werden. Wie mache ich das? HAbt ihr etwas Code für mcih?

_________________
.::Wissen ist Macht, nichts wissen macht nichts::.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 27.01.03 21:01 
Hi,

in einer For-Next-Schleife gehst Du rückwärts alle Items durch:
ausblenden Quelltext
1:
For i := ListBox1.Items.Count -1 DownTo 0 Do					

dann prüfst Du nach ob die ersten vier zeichen nicht mit line übereinstimmen:
ausblenden Quelltext
1:
If Copy (ListBox1.Items [i], 1, 4) <> 'line' Then					

wenn das der Fall ist kannst Du es mit Delete löschen
ausblenden Quelltext
1:
  ListBox1.Items.Delete (i);					

Gruß
TINO
webmaker Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 205



BeitragVerfasst: Mo 27.01.03 21:04 
danke. Das ging aber schnell.....

_________________
.::Wissen ist Macht, nichts wissen macht nichts::.