Autor |
Beitrag |
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Mo 15.07.02 18:25
Tach Leute,
hab mal wieder ein Listboxproblem . Genauer gesagt zwei.
1. Wie kann ich in einer Listbox Einträge suchen. Also so wie bei Datenbanken klappte es nicht.Also eingabe in einem Editfeld.
2. Wie finde ich heraus, wieviele Einträge in einer Listbox stehen.Ich hab mal was mit count probiert, hat aber leider nicht funktioniert.
Vielen Dank für alle Antworten
majolo
PS: Ich glaube, wenn ich genug über ListBoxen weiß, verfasse ich noch nen Tutorial. Mit keiner Komponente habe ich soviele Probleme gehabt.
|
|
DeCodeGuru
Beiträge: 1333
Erhaltene Danke: 1
Arch Linux
Eclipse
|
Verfasst: Mo 15.07.02 18:37
Hi majolo,
zu 2: ListBox1.Items.Count
zu 1: Man könnte mit ner for..to..do-schleife die Einträge durchgehen und überprüfen, ob der Eintrag den entsprechenden Wert hat. Wenn ja, bricht man die Schleife ab und makiert den Eintrag.
_________________ Viele Grüße
Jakob
|
|
aogwaba
Beiträge: 109
|
Verfasst: Mo 15.07.02 18:39
zu 2.StringList.items.indexOf('mytext')
cu
waba
Code-Tag hinzugefügt. Marc
|
|
Klabautermann
Beiträge: 6366
Erhaltene Danke: 60
Windows 7, Ubuntu
Delphi 7 Prof.
|
Verfasst: Mo 15.07.02 18:40
Hallo,
majolo hat folgendes geschrieben: | 1. Wie kann ich in einer Listbox Einträge suchen. Also so wie bei Datenbanken klappte es nicht.Also eingabe in einem Editfeld. |
Diese funktion liefert dir, in welcher Zeile der übergebene String (TXT) das erste mal vorkommt.
Quelltext 1: 2: 3: 4:
| procedure FingString(TXT :STRING); BEGIN Result := ListBox1.Items.IndexOf(TXT); END; |
majolo hat folgendes geschrieben: | 2. Wie finde ich heraus, wieviele Einträge in einer Listbox stehen.Ich hab mal was mit count probiert, hat aber leider nicht funktioniert. |
Count ist schon richtig, und zwar
Quelltext 1:
| Anzahl := ListBox1.Items.Count; |
majolo hat folgendes geschrieben: | PS: Ich glaube, wenn ich genug über ListBoxen weiß, verfasse ich noch nen Tutorial. Mit keiner Komponente habe ich soviele Probleme gehabt. |
Dann arbeite mal mit einer ListView. Die bitet viel mehr möglichkeiten, wird dir aber wahrscheinlich auch mehr Probleme machen.
Gruß
Klabautermann
|
|
DeCodeGuru
Beiträge: 1333
Erhaltene Danke: 1
Arch Linux
Eclipse
|
Verfasst: Mo 15.07.02 18:48
Stimmt, mit ListBox1.Items.IndexOf kann man suchen, habe ich vergessen.
_________________ Viele Grüße
Jakob
|
|
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Mo 15.07.02 19:20
Vielen Dank für alle Anworten.Ihr habt mir geholfen.Delphi-Forum ist und bleibt das Beste
majolo
|
|
Tino
Beiträge: 9839
Erhaltene Danke: 45
Windows 8.1
Delphi XE4
|
Verfasst: Mo 15.07.02 23:42
Ich glaube die Procedure von Klabautermann FindString sollte als Function implementiert sein:
Quelltext 1: 2: 3: 4:
| function FingString(TXT :STRING): Integer; BEGIN Result := ListBox1.Items.IndexOf(TXT); END; |
|
|
Klabautermann
Beiträge: 6366
Erhaltene Danke: 60
Windows 7, Ubuntu
Delphi 7 Prof.
|
Verfasst: Di 16.07.02 02:31
Tino hat folgendes geschrieben: | Ich glaube die Procedure von Klabautermann FindString sollte als Function implementiert sein: |
Ups,
selbstverständlich. Nacha, die beschwerden währen schon gekommen
Gruß
Kalbautermann
|
|
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Di 16.07.02 22:31
Nicht schlimm. Beim Einfügen in den Quellcode ist es mir auch aufgefallen.
Gruß majolo
|
|
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Mi 17.07.02 22:46
@Klabautermann: Kann ich ne Listview, denn genauso wie ne ListBox ansprechen?
MFG
majolo
|
|
Klabautermann
Beiträge: 6366
Erhaltene Danke: 60
Windows 7, Ubuntu
Delphi 7 Prof.
|
Verfasst: Do 18.07.02 00:45
majolo hat folgendes geschrieben: | Kann ich ne Listview, denn genauso wie ne ListBox ansprechen? |
Nein. Eine List View ist bietet wesentlich mehr funktionen und ist deshalb auch etwas komplizierter in der bedienung. So ist z.B. jeder eintrag in einer Listview ein eigenes Objekt und nicht "bloß" ein String. Er muss also auch über einen Constructor erzeugt werden. Daführ hast du dan vorteile wie verschiedenen ansichten (Im grunde die ansichten die du im Windows Explorer einstellen kannst) inclusive mehrerer Spalten usw.
Es lohnt sich auf jeden Fall diese Komponenten kennenzulernen. Aber ein Grundverständnis von Objektorientierter Programmierung ist voraussetzung da sonst vieles unnötig kompliziert erscheint.
Gruß
Klabautermann
|
|
majolo
Beiträge: 334
Ubuntu 8.04, WinXP Prof.
D1, D6Pers, D7 Prof., D8 Prof., D2005 Pers
|
Verfasst: Fr 19.07.02 13:44
Gut ich werde mir mal ListView reinziehen.
majolo
|
|