mybox.Checked := true;
Setting TRadioButton to checked (by code) causes OnClick event handler to be called.
How can I recognize if user is
TRadioButton
(like TCheckBox) provides a protected property ClicksDisabled
that can help you.
I use class helpers to add the needed functionality:
RadioButton1.SetCheckedWithoutClick(False);
with the following class helper for a VCL TRadioButton
:
TRadioButtonHelper = class helper for TRadioButton
procedure SetCheckedWithoutClick(AChecked: Boolean);
end;
procedure TRadioButtonHelper.SetCheckedWithoutClick(AChecked: Boolean);
begin
ClicksDisabled := True;
try
Checked := AChecked;
finally
ClicksDisabled := False;
end;
end;