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

Asked

Viewed 397 times

0

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

I used radiobutton3.checked at the event OnClick image but did not work.

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

  • 1

    I did exactly what I said and it worked right here for me, if there are some code snippets to help more.

  • Gabriel, if the @Tmc answer does not resolve, [Edit] your question and post the code you are using, which image component used ...

2 answers

3


To do this is enough to add the following code in the event onclick of imagem3, and the Radiobutton will pass to check in:

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

Another thing that can be done is pass the others Radiobuttons to false, simply adding 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 put.

2

Implements the following code:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.