Autor Beitrag
saeschman
Hält's aus hier
Beiträge: 5

Win 98 SE, Win XP Prof SP2, SuSe Linux 9.3 Prof
D7 Prof
BeitragVerfasst: Do 15.09.05 06:34 
Hallo!

Ich habe ein kleines Problem, und zwar wollte ich in einem Programm eine RadioGroup einsetzen.

Jetzt ist mein Problem, dass ich die einzelenen Buttons so programmieren wollte, dass beim Klick darauf jeweils ein anderes Ereigniss ausgelöst wird. Mein erster Gedanke war diese per if zu Lösen

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TFormIntZeit.RadioGroup1Click(Sender: TObject);
begin
  if Sender = RadioButton1 then send(17,'ITIM1', status)
  if Sender = RadioButton2 then send(17,'ITIM2', status) 
  if Sender = radioButton3 then send(17,'ITIM3', status)
end;


darin sagt er aber er kennt den RadioButton1 2 und 3 nicht. Woran liegt das? Wie muss ich das hier lösen?

Im voraus schon mal vielen Dank für euere Bemühungen und eure Hilfe.

mit freundlichen Grüßen

Sascha
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Do 15.09.05 06:58 
Hallo,

die Radiobuttons der RadioGroup werden in der Eigenschaft Items verwaltet, das ausgewählte Item kannst Du über ItemIndex ermitteln.
So in etwa könntest Du dein Problem lösen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.RadioGroup1Click(Sender: TObject);
begin
  case RadioGroup1.ItemIndex of
   0 : showmessage('Item 0 ausgewählt');
   1 : showmessage('Item 1 ausgewählt');
   2 : showmessage('Item 2 ausgewählt');
  end
end;

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
saeschman Threadstarter
Hält's aus hier
Beiträge: 5

Win 98 SE, Win XP Prof SP2, SuSe Linux 9.3 Prof
D7 Prof
BeitragVerfasst: Do 15.09.05 07:27 
Hallo!

Danke für die schnelle Antwort!

Sie hat mein Problem gelöst!

mfg

Sascha
mustermannxx
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 20

WinXP prof
Delphi 2005 Pers
BeitragVerfasst: Sa 17.09.05 15:09 
knüpfe mal an, ich hab ein fenster das ich öffnen lasse nachdem ich in nem fenster davor was in edit boxen schreiben (das hab ich in vars gespeichert) lassen habe.
jetzt will ich in dem neuen fenster die radiobuttons (die in na radiogroup sind) nach den vars bennen, also das die namen direkt nach dem öffnen so benannt sind.

mfg mustermannxx
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Sa 17.09.05 23:29 
Hallo,

ist abhängig davon, ob Du in der RadioGroup schon Einträge hast oder nicht.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
//Ein RadioGroup-Item ändern:
Form2.RadioGroup1.Items[0] := sTemp;

//Ein RadioGroup-Item neu anlegen:
Form2.RadioGroup1.Items.Add(sTemp);

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
mustermannxx
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 20

WinXP prof
Delphi 2005 Pers
BeitragVerfasst: So 18.09.05 08:38 
hi, großes thx :D hast mir ne umständliche procedure erspart :D

mfg mustermannxx