Autor Beitrag
drummer83
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Di 03.04.07 23:20 
Hallo,

ich suche nach einer Möglichkeit per Schleife auf verschiedene ComboBoxes zuzugreifen. Es gibt also z.B. ComboBox1, ComboBox2, ComboBox3. Und ich will dann so etwas haben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i:=1 to 3 do
begin
 ComboBox'i'.ItemIndex:= i;
end;


Dabei ist sicherlich ComboBox'i' falsch, aber muss doch eine Möglichkeit geben so etwas umzusetzen, oder?

Vielen Dank schon mal für Eure Antworten.


Zuletzt bearbeitet von drummer83 am Di 03.04.07 23:46, insgesamt 1-mal bearbeitet
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: Di 03.04.07 23:26 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i := 1 to 3 do
begin
 (FindComponent(ComboBox + 'i'as TComboBox).ItemIndex := i;
end;


So sollte das eigentlich klappen. Achja, nächstes mal bitte [ delphi ] anstatt [ code] für Delphi-Quelltext benutzen ;)
drummer83 Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Di 03.04.07 23:56 
Danke schon mal...

Da bekomme ich leider die Meldung:

Undeclared identifier: 'ComboBox'

Hab den Beitrag oben von [code] zu [delphi] geändert :wink:
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: Di 03.04.07 23:59 
Huch sorry, hab mich vertippt

ausblenden Delphi-Quelltext
1:
2:
3:
4:
for i := 1 to 3 do
begin
 (FindComponent('ComboBox' + inttostr(i)) as TComboBox).ItemIndex := i;
end;


sry, bin grad noch etwas sehr in PHP drin .- hab die letzten paar Monate kein Delphi mehr geproggt.
drummer83 Threadstarter
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Mi 04.04.07 00:04 
Den inttostr hast du auch noch später eingebaut, oder? :wink:

Aber so funktionierts. Super. Danke.

Ich liebe schnelle Foren... :D
Danniolo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 693



BeitragVerfasst: Mi 04.04.07 00:11 
user profile icondrummer83 hat folgendes geschrieben:
Den inttostr hast du auch noch später eingebaut, oder? :wink:

Aber so funktionierts. Super. Danke.

Ich liebe schnelle Foren... :D


Jo, hab ich^^
Wie gesagt, ich bin grad noch etwas von php verwöhnt - da werden die Typen automatisch umgewandelt XD