Mega Code Archive

 
Categories / Delphi / VCL
 

How to change the OnClick behavior of a TRadioButton, TCombobox

Title: How to change the OnClick behavior of a TRadioButton, TCombobox procedure ChangeRadiobuttonState(ARadiobutton: TRadiobutton; checkit: Boolean); var oldhandler: TNotifyEvent; begin oldhandler := ARadiobutton.Onclick; ARadiobutton.Onclick := nil; ARadiobutton.Checked := checkit; ARadiobutton.OnClick := oldhandler; end; // To make the combobox "click" after setting the item index simply call its // Click method. The control inherits this method from TControl, but it is // protected. So you need a bit of hoop-jumping: Type TComboCracker = class(TCombobox); procedure SetComboboxIndex(ACombobox: TCombobox; Index: Integer); begin ACombobox.ItemIndex := Index; TCombocracker(ACombobox).Click; end;