Hi, i am trying to get my application to check, which radiobutton is selected, and then perform instructions based on the selection.

but i cant seem to use a IF and ELSE procedure to do this, can somebody help me out as to what procedure i should use.

Recommended Answers

All 4 Replies

one form,two radio buttons as radiobutton1 and radiobutton2 and a simple button as button1,place them onto the form and code the button1 as

procedure TForm1.Button1Click(Sender: TObject);
begin
        if radiobutton1.Checked = true then begin
                radiobutton2.Checked:=false;
                showmessage('radiobutton1 is selected');
        end else begin
                showmessage('radiobutton2 is selected');
        end;
end;

this is it..... :D

or you can use case structure too :D

procedure TForm1.Button1Click(Sender: TObject);
begin
case radiobutton1.Checked of
        true:showmessage('radiobutton1 is selected');
        false:showmessage('radiobutton1 is unchecked');
end;
end;

:D
by the way the If..then..else is a structure not procedure :idea:

Hi, i am trying to get my application to check, which radiobutton is selected, and then perform instructions based on the selection.

but i cant seem to use a IF and ELSE procedure to do this, can somebody help me out as to what procedure i should use.

With a Radio group of RG, with 2 radio buttons Radio1 and Radio2 entered in the RG. items property.

Do a Radiogroup on click event and put in the following:

procedure TForm1.RGClick(Sender: TObject);
begin
  CASE RG.itemindex OF
          0 : { Do something }
          1 : { Do Something else }
 End;
end;

Alternatively you could trigger the case statement on the press of an apply or OK button.

Hope that helps

PQ

thanks again flamingclaw for your help, sorry havent marked thread as solved sooner, been away working.

Thanks quaifp1 too for your reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.