Autor Beitrag
spongeBHV
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34



BeitragVerfasst: Di 13.02.07 19:07 
hi

ich habe ein formular, das 10 radiobuttons hat (radiobutton1...10). durch ein array in der if- anweisung soll überprüft werden, welcher dieser radiobuttons gecheckt ist. so sieht der quellcode grad aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.ButtonOKClick(Sender: TObject);
var
radiobuttonnummer:  array [1..10] of integer;
i: integer;

radiobuttonnummer[1] := RadioButton1;
...

for i = 1 to 10 do
   if radiobuttonnummer[i].checked := true then
   buttonok.enabled := true;
end;


kann mir jemand sagen warum das nicht geht und wenn ihr es wisst schreibt mal bitte wie es geht.

danke euch sehr im voraus
sponge
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Di 13.02.07 19:14 
Du weist einem integer einen Radiobutton zu!
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.ButtonOKClick(Sender: TObject);
var
radiobuttonnummer:  array [1..10] of integer;
i: integer;

radiobuttonnummer[1] := RadioButton1; //hier!!!
...

for i = 1 to 10 do
   if radiobuttonnummer[i].checked := true then
   buttonok.enabled := true;
end;

So geht's:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.ButtonOKClick(Sender: TObject);
var
i: integer;
begin
...

for i = 1 to 10 do
   if (TRadioButton(FindComponent('RadioButton' + inttostr(i)).Checked) = true) then
   buttonok.enabled := true;
end;

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Kroko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1284

W98 W2k WXP
Turbo D
BeitragVerfasst: Di 13.02.07 19:14 
entweder
als array of TRadioButton mit Vergleich nur =
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.ButtonOKClick(Sender: TObject);
var
  radiobuttonnummer:  array [1..10] of TRadioButton;
  i: integer;
begin
radiobuttonnummer[1] := RadioButton1;
...

for i = 1 to 10 do
   if radiobuttonnummer[i].checked then
   buttonok.enabled := true;
end;

oder
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.ButtonOKClick(Sender: TObject);
var
  i: integer;
begin
for i = 1 to 10 do
   if TRadioButton(FindComponent('RadioButton'+IntToStr(I))).checked then
   buttonok.enabled := true;
end;

_________________
Die F1-Taste steht nicht unter Naturschutz und darf somit regelmäßig und oft benutzt werden! oder Wer lesen kann, ist klar im Vorteil!
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Di 13.02.07 20:20 
Würde sich dafür nicht eine RadioGroup anbieten? :wink:

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.