ich habe folgendes Problem bei der Aktualisierung von ListBoxen:
Ich verwende drei Auswahllisten (Typ TListBox). Immer wenn ein neuer Eintrag in ListBox1 ausgewählt wird, soll die ListBox2 mit neuen Werten gefüllt werden und immer wenn ein Eintrag in ListBox2 ausgewählt wird, soll ListBox3 entsprechend aktualisiert werden.
Code: Alles auswählen
procedure TForm1.FormShow(Sender: TObject);
begin
ListBox1.Items.Add('1');
ListBox1.Items.Add('2');
ListBox1.Items.Add('3');
ListBox1.ItemIndex := 0;
end;
procedure TForm1.ListBox1SelectionChange(Sender: TObject; User: boolean);
var
I: Integer;
S: String;
begin
ShowMessage('ListBox1SelectionChange');
S := ListBox1.Items[ListBox1.ItemIndex] + '.';
ListBox2.Items.Clear;
for I := 1 to 3 do ListBox2.Items.Add(S + IntToStr(I));
ListBox2.ItemIndex := 0;
end;
procedure TForm1.ListBox2SelectionChange(Sender: TObject; User: boolean);
var
I: Integer;
S: String;
begin
ShowMessage('ListBox2SelectionChange');
S := ListBox2.Items[ListBox2.ItemIndex] + '.';
ListBox3.Items.Clear;
for I := 1 to 3 do ListBox3.Items.Add(S + IntToStr(I));
ListBox3.ItemIndex := 0;
end;
Wenn ich allerdings jetzt in ListBox1 einen beliebigen Wert auswähle (durch DropDown), wird nur die SelectionChange-Methode von ListBox1 ausgeführt, die von ListBox2 nicht. Demnach wird auch die dritte Liste nicht aktualisiert.
Woran liegt das und wie kann ich diesen Fehler beheben?
Viele Grüße
Kay