surfbored
asked on
Change Radio Group Without Firing OnClick
I have a radio group that has an onClick event that works correctly. However, when I change the itemIndex value through code, the onClick event fires too. How can I suppress the unwanted onClick (which in my mind should actually be an "onChange" event) event?
Thanks for any ideas.
Thanks for any ideas.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Quick and easy, that's just the kind of answers I like!!! Thanks!
There are other more complex methods you could use as well. Adding a variable to indicate when you are manually changing the ItemIndex
eg
private
FIndexChanging: Integer;
protected
property IndexChanging: Boolean read GetIndexChanging write SetindexChanging;
end
function TForm1.GetIndexChanging: boolen
begin
Result := FIndexChanging>0;
end;
procedure TForm1.SetIndexChanging(va
begin
if Value then
Inc(FIndexChanging)
else if FIndexChanging >0 then
Dec(FIndexChanging) ;
end;
TForm1.RadioGroup1Click(Se
begin
if IndexChanging then
Exit;
..........continue with your code
end;
//when changing index
IndexChanging := True;
try
RadioGroup1.ItemIndex := 1; //your value
................
finally
IndexChanging := False;
end;