greenspun.com : LUSENET : OCI Best Practices : One Thread

TSimpleCheckBox is a OCI custom component that avoids a potential problem with the TCheckBox class.

TCheckBox objects "link" the Click event and the check box Checked and State properies: Clicking on a check box (or running the Click) method runs OnClick and toggles the Checked property, and changing the Checked property runs click. This often leads to recursion, especially in situations like ours where the the UI is so well separated from the associated business object.

TSimpleCheckBox is a custom component that has two uses: if you want it to behave like a TCheckBox set its Behavior property to scStandard. If you want to de-couple the click event from the Checked property set Behavior to the other option: scSimple. With this setting TSimpleCheckBox behaves like TMenuItem. Like a TMenuItem object, a TSimpleCheckBox object set to scSimple has an OnClick event and a Checked property, but they are not linked.


If you need a checkbox that reflects a property setting of some other object then use scSimple. In this case you will ONLY set the Checked property in response to some kind of change event associated with the object.

If you need a checkbox that behaves like the standard check box then set Behavior to scStandard (or use a TCheckBox component). In this case you will probably not need to set the Checked property in your code.

As a rule-of-thumb:

-- Anonymous, July 10, 1998

Moderation questions? read the FAQ