Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Probleme bei ComboBox (https://www.delphipraxis.net/93397-probleme-bei-combobox.html)

Lill Jens 5. Jun 2007 10:21


Probleme bei ComboBox
 
Hallo!

Ich hab folgende Frage:

Ich arbeite an einem Programm das so funktionieren soll:

Wenn man in der ersten ComboBox ein Item auswählt soll eine dazugehörige zweite ComboBox erscheinen!

Sprich ich wähle Item 'Haus' in der ersten ComboBox aus soll eine zweite ComboBox erscheinen mit anderen Items.

Wähle ich in der ersten ComboBox Item 'Tier' aus soll wieder eine neue ComboBox erscheinen mit den dazugehörigen Items.

Kann man das ganze über den ItemIndex machen? Bin anfänger und hab null ahnung!

Thx für eure antworten


Lg Lill Jens

DeddyH 5. Jun 2007 10:32

Re: Probleme bei ComboBox
 
Mal ein sinnfreies Beispiel (mit Abfrage des ItemIndex, Du hast richtig vermutet :-D )
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
  ComboBox1.Style := csOwnerDrawFixed;
  with ComboBox1.Items do
    begin
      Add('Erstes Thema');
      Add('Zweites Thema');
      Add('Drittes Thema');
    end;
  ComboBox1.ItemIndex := 0;
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  ComboBox2.Items.Clear;
  case ComboBox1.ItemIndex of
    0: begin
         with ComboBox2.Items do
           begin
             Add('Item 1 zu Thema 1');
             Add('Item 2 zu Thema 1');
             Add('Item 3 zu Thema 1');
           end;
       end;
    1: begin
         with ComboBox2.Items do
           begin
             Add('Item 1 zu Thema 2');
             Add('Item 2 zu Thema 2');
             Add('Item 3 zu Thema 2');
           end;
       end;
    2: begin
         with ComboBox2.Items do
           begin
             Add('Item 1 zu Thema 3');
             Add('Item 2 zu Thema 3');
             Add('Item 3 zu Thema 3');
           end;
       end;
  end;
  ComboBox2.ItemIndex := 0;
end;

Lill Jens 5. Jun 2007 10:37

Re: Probleme bei ComboBox
 
Super funktioniert wunderbar!

Dankeschön!

Lg Lill Jens


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:58 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz