Doubt to "check" a radiobutton when clicking on an image

0

I have these 3 images with 3 RadioButtons different, I would like to click on the image of the blank square for example, its RadioButton is selected.

I used radiobutton3.checked in event OnClick of image but did not work.

In the image are three rectangles painted differently, with RadioButtons next to each. None of them is marked as selected.

    
asked by anonymous 13.06.2016 / 20:30

2 answers

3

To do this, just add the following code in the onclick event of the imagem3 , and the RadioButton will change to check :

procedure TForm1.Image3Click(Sender: TObject);
begin
  radiobutton3.Checked := True;
end;

Another thing that can be done is to pass the other RadioButtons to false , just add the following code:

procedure TForm1.Image3Click(Sender: TObject);
begin
  radiobutton1.Checked := False;
  radiobutton2.Checked := False;
  radiobutton3.Checked := True;
end;

If you have any more questions, please.

    
15.06.2016 / 13:21
2

Implements the following code:

procedure TForm1.Image1Click(Sender: TObject);
begin
  RadioButton1.Checked := Sender = Image1;
  RadioButton2.Checked := Sender = Image2;
  RadioButton3.Checked := Sender = Image3;
end;
    
17.06.2016 / 20:28