Autor Beitrag
Marco15
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Mi 27.04.05 14:01 
Hi Delphi-Progger!

Wie kann ich:

Also, ich habe einen Suchen_Button, der eine Listbox durchsucht. Jetzt möchte ich, dass er den gefundenen item markiert. Wie geht das? :)

Moderiert von user profile iconTino: Titel geändert.
Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Mi 27.04.2005 um 15:13

_________________
Ich bin nur Schüler.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 27.04.05 14:07 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
begin
for i := 0 to ListBox1.Count-1 do ListBox1.Selected[i] := False;
// Hier kommt die Suche hin. x sollte danach die Zeile sein, die
// ausgewählt werden soll.
ListBox1.Selected[x] := True;
end;


;)
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Mi 27.04.05 14:23 
Aber wie markiert er dann den gefundenen item?

Das macht er nämlich noch nicht, da liegt mein einziges Problem

Moderiert von user profile iconChristian S.: Beiträge zusammengefasst

_________________
Ich bin nur Schüler.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 27.04.05 14:27 
Tut er nicht?? :eyes:
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 27.04.05 14:28 
Poste mal den Code, wo du suchst... ;)
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Mi 27.04.05 14:30 
was meinst du mit, wo du suchst?

_________________
Ich bin nur Schüler.
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 27.04.05 14:31 
user profile iconMarco15 hat folgendes geschrieben:
Also, ich habe einen Suchen_Button, der eine Listbox durchsucht. Jetzt möchte ich, dass er den gefundenen item markiert. Wie geht das? :)


;)
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Mi 27.04.05 14:33 
Also, ich gebe einen Namen in ein editfeld ein, drücke auf den duchen_button, er durchsucht die listbox danach, und jetzt will ich, dass er diesen gefundenen item in der listbox markiert.

_________________
Ich bin nur Schüler.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mi 27.04.05 14:38 
So wie es in deinem Beitrag steht, gibt es nur ein Item zu selektieren. Dann reicht doch das hier (MultiSelect ist false):
ausblenden Delphi-Quelltext
1:
2:
 with ListBox1 do
  ItemIndex := Items.IndexOf('Apfel');


//Edit: (Detail korrigiert)


Zuletzt bearbeitet von delfiphan am Mi 27.04.05 14:59, insgesamt 1-mal bearbeitet
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Mi 27.04.05 14:41 
und wie geht das dann, dass er den gefundenen markiert, ich habe das mit nem array gemacht,

nachname
vorname
tel

ich will nach dem nachnamen suchen, wenn er ihn gefunden hat soller diesen item markieren.

_________________
Ich bin nur Schüler.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 27.04.05 14:44 
user profile iconMarco15 hat folgendes geschrieben:
wenn er ihn gefunden hat soller diesen item markieren.

Hast du dir mal die Lösungen hier im Topic angeschaut? Vor allem die Antwort über Deinem Beitrag?
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Mi 27.04.05 14:47 
tut mir leid, aber ich arbeite jetzt seit einem viertel jahr mit delphi in der schule und das verstehe ich einfach nicht.

_________________
Ich bin nur Schüler.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 27.04.05 14:52 
Hallo!

Was steht in der Listbox? Steht in der Listbox genau der Text, nach dem auch gesucht wird? Oder muss in dem Array gesucht werden und dann ein entsprechendes Item in der Listbox markiert werden?

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Mi 27.04.05 14:59 
ja ich suche im array.

_________________
Ich bin nur Schüler.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mi 27.04.05 15:02 
Okay, dann hast du die Frage falsch gestellt.
Könntest du uns evtl. etwas Code posten?
Michael15
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76

Win XP Professional
Delphi 2, 3, 7, 8
BeitragVerfasst: Mi 27.04.05 15:02 
ich glaube er meint:
ich möchte in edit1 einen listboxeintrag suchen,
wenn der listboxeintag aus einem array vorhanden ist soll er dieses item in der listbox markieren. (nur wie ????)
WeBsPaCe
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2322
Erhaltene Danke: 1

FireFox 3, Internet Explorer 6 SP1
D1, D3Prof, D6Pers, D7Pers+Indy, VisualStudio Express
BeitragVerfasst: Mi 27.04.05 15:05 
:rofl: Was ist los??? :lol: :rofl:

Ich glaube es wäre am besten, wenn uns Marco15 einfach nochmal ganz ausführlich erklärt, was er hat und was er haben will. ;)
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Mi 27.04.05 15:12 
Also, da ist ne listbox, ein editfeld und ein button.
in der listbox stehen items, die sich zusammen setzen aus dem Typ Tds.
So ich will jetzt nach dem Nachnamen suchen,
also wäre es ja

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
const max = 6;

Tds = record
        vorname  : string[25];                                         
        nachname : string[25];
        tel      : string[25];
      end;

      Tbox = array [1..max] of Tds;

var box : Tbox;


procedure suche(x:Tbox);
var i: integer;
begin
  for i := 1 to max do
    begin
      if x[i].vorname = form1.Edit1.Text then
        begin
          
         ???????????????????????????????????????????
        end;
    end;
end;

Wenn er den Nachnamen gefunden hat, soll er den ganzen item markieren.

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt.

_________________
Ich bin nur Schüler.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 27.04.05 15:14 
Stehen die Items in der selben Reihenfolge in der Listbox, wie sie auch im Array stehen? (Am Besten postest Du noch die Routine, mit der Du die Listbox befüllst.)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Marco15 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 98

Win XP Prof.
D2 Schüleredition, D7
BeitragVerfasst: Mi 27.04.05 15:16 
Sorry, aber was ist die Routine???

_________________
Ich bin nur Schüler.