Autor Beitrag
Hack Gott
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: So 21.08.05 21:29 
Hi,
also ich hab ein edit1 und eine listbox1, jetzt will ich das die ListBox1 nur noch Einträge anzeigt die mit Edit1 zu tun haben, geht das irgendwie?
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: So 21.08.05 21:34 
Omg... Wieder ein sehr präziser Text. ;) Wie kann ein ListBox-Eintrag was mit einem Edittext zu tun haben?

:arrow: Ausführlicher, eventuell Beispiel... ;)
OneOfTen
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 21.08.05 21:41 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
ListBox.Items.Clear;
ListBox.Items.Add("blabla");
ListBox.Items.Count;
ListBox.Items.Delete(Index);


die Eigenschaften kombiniert mit ner For-Schleife hilft bestimmt
Hack Gott Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: So 21.08.05 22:05 
OK, ein Beispiel:

in meiner ListBox stehen folgende Einträge:

Delphi 2005
Delphi 7
C
C++

so, und jetzt soll wenn man in edit1 D, De, Del, usw. nur noch folgende Einträge zu sehen sein:

Delphi 2005
Delphi 7

wenn man aber C eingibt:

C
C++

Besser?
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: So 21.08.05 22:46 
Hallo,

da die Listbox anscheinend das Ergebnis einer Filterung ausgeben soll, speicher doch die Gesamtauflistung in einer StringList.
Darin kannst Du dann entsprechend der Vorgabe im Edit suchen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var z : Integer;
begin
  ListBox1.Items.Clear;
  for z := 0 to MyStringList.Count-1 do
    begin
      if Pos(Edit1.Text,MyStringList[z]) > 0 then
        ListBox1.Items.Add(MyStringList[z]);
    end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
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: So 21.08.05 22:52 
Sehr schön. ;) Jetzt hab ich verstanden, was du meinst. Warum nicht gleich so? :tongue:

ListBox1 ist die ListBox mit dem gefilterten Inhalt. ListBox2 ist die "Quelle", die bei Edit1.Change gefiltert wird. ;)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.Edit1Change(Sender: TObject);
var
  i, j: Integer;
  s: String;
begin
  ListBox1.Clear;
  if Edit1.Text = '' then
    Exit;
  for i := 0 to ListBox2.Count - 1 do
    begin
      s := '';
      for j := 1 to Length(Edit1.Text) do
        s := s + ListBox2.Items[i][j];
      if s = Edit1.Text then
        ListBox1.Items.Add(ListBox2.Items[i]);
    end;
end;


//EDIT: Zu spät... :motz: ;)
Hack Gott Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 409

Windows Vista
Delphi 2005 Personal, Delphi 7
BeitragVerfasst: Mo 22.08.05 11:37 
Hmm, das klappt ja jetzt auch alles wunderbar, aber der berüksichtigt jetzt ja die Groß- und Kleinschreibung, das sollte er eigentlich nicht tun.
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: Mo 22.08.05 11:45 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
procedure TForm1.Edit1Change(Sender: TObject);
var
  i, j: Integer;
  s: String;
begin
  ListBox1.Clear;
  if Edit1.Text = '' then
    Exit;
  for i := 0 to ListBox2.Count - 1 do
    begin
      s := '';
      for j := 1 to Length(Edit1.Text) do
        s := s + ListBox2.Items[i][j];
      if LowerCase(s) = LowerCase(Edit1.Text) then
        ListBox1.Items.Add(ListBox2.Items[i]);
    end;
end;


;)