RAD Studio
ContentsIndex
PreviousUpNext
Handling Boolean Field Values with Check Boxes

TDBCheckBox is a data-aware check box control. It can be used to set the values of Boolean fields in a dataset. For example, a customer invoice form might have a check box control that when checked indicates the customer is tax-exempt, and when unchecked indicates that the customer is not tax-exempt. 

The data-aware check box control manages its checked or unchecked state by comparing the value of the current field to the contents of ValueChecked and ValueUnchecked properties. If the field value matches the ValueChecked property, the control is checked. Otherwise, if the field matches the ValueUnchecked property, the control is unchecked.

Note: The values in ValueChecked and ValueUnchecked cannot be identical.
Set the ValueChecked property to a value the control should post to the database if the control is checked when the user moves to another record. By default, this value is set to "true," but you can make it any alphanumeric value appropriate to your needs. You can also enter a semicolon-delimited list of items as the value of ValueChecked. If any of the items matches the contents of that field in the current record, the check box is checked. For example, you can specify a ValueChecked string like:

DBCheckBox1.ValueChecked := 'True;Yes;On';

 

DBCheckBox1->ValueChecked = "true;Yes;On";

If the field for the current record contains values of "True," "Yes," or "On," then the check box is checked. Comparison of the field to ValueChecked strings is case-insensitive. If a user checks a box for which there are multiple ValueChecked strings, the first string is the value that is posted to the database. 

Set the ValueUnchecked property to a value the control should post to the database if the control is not checked when the user moves to another record. By default, this value is set to "false," but you can make it any alphanumeric value appropriate to your needs. You can also enter a semicolon-delimited list of items as the value of ValueUnchecked. If any of the items matches the contents of that field in the current record, the check box is unchecked. 

A data-aware check box is disabled whenever the field for the current record does not contain one of the values listed in the ValueChecked or ValueUnchecked properties. 

If the field with which a check box is associated is a logical field, the check box is always checked if the contents of the field is True, and it is unchecked if the contents of the field is False. In this case, strings entered in the ValueChecked and ValueUnchecked properties have no effect on logical fields.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!