was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

36 Visitors Online


 
...das OnClick Verhalten von einem TRadioButton, TCombobox ändern?
Autor: P. Below
Homepage: http://www.teamb.com
[ Tip ausdrucken ]  

Tip Bewertung (9):  
     


// 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;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners