Карта сайта Kansoftware
НОВОСТИУСЛУГИРЕШЕНИЯКОНТАКТЫ
Разработка программного обеспечения
KANSoftWare

Изменить поведение при нажатии для TRadioButton или TComboBox

Delphi , Компоненты и Классы , Флажки

Изменить поведение при нажатии для TRadioButton или TComboBox

Оформил: DeeCo
Автор: http://www.swissdelphicenter.ch

// Q: It appears that programatically setting Item.Index for the Radio Button 
// fires the onClick event.  It also appears  doing the same for the 
// ComboBox does NOT fire the OnClick event. Does another property the two 
// control effect this behavior. 

// A: No, it is caused by the way Windows sends the notifications that fire the 
// event when the control state is changed by a program action. 

// Q: I have an instance where I need each of 
// the control to exhibit the opposite behavior. 

// A: For a TRadiobutton you can disconnect the OnClick handler, change the 
// state, then reconnect the handler. 

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;

Статья Изменить поведение при нажатии для TRadioButton или TComboBox раздела Компоненты и Классы Флажки может быть полезна для разработчиков на Delphi и FreePascal.


Комментарии и вопросы


Ваше мнение или вопрос к статье в виде простого текста (Tag <a href=... Disabled). Все комментарии модерируются, модератор оставляет за собой право удалить непонравившейся ему комментарий.

заголовок

e-mail

Ваше имя

Сообщение

Введите код




Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.



:: Главная :: Флажки ::


реклама



©KANSoftWare (разработка программного обеспечения, создание программ, создание интерактивных сайтов), 2007
Top.Mail.Ru Rambler's Top100
28.03.2024 14:23:57/0.033145904541016/0