Autor Beitrag
nilsener1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52

Win 98, XP
D4 prof.
BeitragVerfasst: Di 05.10.04 21:23 
Hallo,

ich habe 3 ComboBoxes und unter Properties/Items eine Stringliste für die Auswahl definiert. Ich möchte durch Anklicken eines Buttons den in ComboBox1 ausgewählen String automatisch auch in ComboBox 2 und 3 anwählen. Für den Fall, dass der User in allen 3 ComboBoxes die selbe Auswahl treffen möchte, braucht er das dann nur einmal in ComboBox1 zu tun und dann den button drücken damit in 2 und 3 automatisch die selbe Auswahl steht.

Dieser Code funktioniert nicht:

ausblenden Delphi-Quelltext
1:
2:
form1.combobox4.text:=form1.combobox3.text;
form1.combobox5.text:=form1.combobox3.text;


Weiss jemand weiter ?

Vielen Dank für Eure Hilfe

Gruss Nils

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt.
Pille
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 105

Windows 7
DelphiXE Prof.
BeitragVerfasst: Di 05.10.04 21:50 
Also bei mir geht das. Der Fehler muss woanders liegen.
Warum form1.....? Steht der Code nicht im gleichen Formular?

mfg Pille
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Di 05.10.04 21:51 
hallo nils!

das ist ein möglicher weg, um dein problem zu lösen...

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TMainDlg.ComboBox1Change(Sender: TObject);
var
  _index: SmallInt;
begin
  Label1.Caption:= ComboBox1.Items[ComboBox1.ItemIndex];
  _index:= ComboBox2.Items.IndexOf(ComboBox1.Items[ComboBox1.ItemIndex]);
  if _index > -1 then
    ComboBox2.ItemIndex:= _index
  else
    ShowMessage('sorry, der eintrag ist in CB2 leider nicht vorhanden')  
end;


mfg, stefan
nilsener1 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52

Win 98, XP
D4 prof.
BeitragVerfasst: Di 05.10.04 22:11 
danke grayfox, funktioniert prima !

gruss nils
grayfox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 800

win98, winXP
D4 Standard; D6 Personal
BeitragVerfasst: Di 05.10.04 22:29 
ich weiss es, denn ich habs ja auch getestet! :wink:
viel spass damit!

mfg, stefan