Einzelnen Beitrag anzeigen

Neg

Registriert seit: 16. Jan 2004
Ort: Berlin
63 Beiträge
 
Delphi 5 Professional
 
#3

Re: Combobox Items Einträge mit bestimmten Kommentar...

  Alt 26. Jan 2004, 23:38
Delphi-Quellcode:
procedure TForm1.TButton1Click(Sender: TObject);
begin
  case ComboBox1.ItemIndex of
    0: Memo1.Text:='Grün ist toll.';
    1: Memo1.Text:='Blau ist super.';
    2: Memo1.Text:='Gelb ist klasse.';
    3: Memo1.Text:='Rot ist schön.';
  else Memo1.Text:='Bitte Farbe auswählen...';
  end;
end;
Oder, wenn du willst, noch etwas kompakter:
Delphi-Quellcode:
const
  cColorComments: Array[0..3] of String = ( 'Grün ist toll.',
    'Blau ist super.', 'Gelb ist klasse.', 'Rot ist schön.' );

procedure TForm1.TButton1Click(Sender: TObject);
begin
  case ComboBox1.ItemIndex of
    0..3: Memo1.Text:=cColorComments[ComboBox1.ItemIndex];
  else Memo1.Text:='Bitte Farbe auswählen...';
  end;
end;
  Mit Zitat antworten Zitat