Autor Beitrag
Webkommissar
Hält's aus hier
Beiträge: 15



BeitragVerfasst: Mi 15.01.03 20:03 
Hi Leute!

Bin ein ziemlicher Anfänger was das Programmieren angeht, wollte deshalb folgendes fragen:

Ich hab ne Groupbox mit vier Radiobuttons. Wie überprüfe ich nun ob ein button überhaupt angeklickt wurde. Will, wenn keiner angeklickt wurde, ein Label erscheinen lassen ("Bitte einen Button aussuchen"). Wie geht das? Irgendwei mit "checked"???

Wäre cool wenn ihr mir helfen könntet!

Danke!

Gruss...

_________________
Bald ist es geschafft - ABI `03 - juuhuuu!!!
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Mi 15.01.03 20:07 
ausblenden Quelltext
1:
if radiobutton1.checked then					

so prüfst du ob eine gecheckt ist
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
if not (radiobutton1.checket) then
if not (radiobutton2.checket) then
if not (radiobutton3.checket) then
if not (radiobutton4.checket) then
begin
..
end;

so prüfst du ob überhaupt einer gechecket ist

Moderiert von user profile iconTino: Code-Tags hinzugefügt.
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Mi 15.01.03 20:46 
also, falls du eine radiogroup hast überprüfst du so ob etwas gechecked ist:

ausblenden Quelltext
1:
2:
if radiogroup1.ItemIndex=-1 then
begin showmessage('blablabla');


außerdem wird checked mit "d" geschrieben!!

Fiji-Fighter
torstenheinze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 461



BeitragVerfasst: Mi 15.01.03 20:48 
ich benutze radiobox net so oft, ich dachte, das das so wie bei der checknbox ist.


das mit dem t und d, :oops:
schreibfehler, und ich hab das dqann immer kopiert, eigendlich weiß ich ja wie man das schreibt
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 16.01.03 10:24 
Wenn Du das Label wirklich nur an und aus schalten willst kannst Du das auch ohne If-Then-Anweisung machen:
ausblenden Quelltext
1:
2:
3:
Label1.Visible := 
  (not RadioButton1.Checked) and (not RadioButton2.Checked) and 
  (not RadioButton3.Checked) and (not RadioButton4.Checked);

Gruß
TINO
Tower
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 99



BeitragVerfasst: Do 16.01.03 10:37 
<Klugscheiß>

DANN wäre das aber noch ein Tick eleganter:
ausblenden Quelltext
1:
Label1.Visible := (RadioGroup1.ItemIndex = -1);					


</Klugscheiß>

...finde ich. :)

==> Wenn kein Item gewählt ist, ist der ItemIndex = -1. Das heißt, was in der Klammer steht, ist TRUE, damit wird das Label1 "visible".
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 16.01.03 10:58 
Von einer RadioGroup war doch nie die Rede, oder?
Tower
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 99



BeitragVerfasst: Do 16.01.03 11:38 
[gucknach]

Stimmt, im Ursprungs-Posting nicht. Die Radiogroup hat Fiji-Fighter mir in den Kopf gesetzt. Der Schlingel... :wink:

Ok, mein Tipp galt natürlich nur für Radiogroups.
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: Do 16.01.03 12:25 
ich wusste nicht genau was er meint...

die radiogroup ist doch auch eine so eine Art groupbox in der man halt nur radiobuttons hat...

ich dachte vielleicht hat der ja so was gemeint...

auch egal, jedenfalls ist es bei ner radiogroup auch einfacher zu überprüfen ob etwas gechecked ist und daher wenn es vom Design her klappt diese vorzuziehen...

Fiji-Fighter