Restricting Field Values with Radio Controls Index

From RAD Studio
Jump to: navigation, search

Go Up to Displaying a Single Record


Vcl.DBCtrls.TDBRadioGroup is a data-aware version of a radio group control. It enables you to set the value of a data field with a radio button control where there is a limited number of possible values for the field. The radio group includes one button for each value a field can accept. Users can set the value for a data field by selecting the desired radio button.

The Items property determines the radio buttons that appear in the group. Items is a string list. One radio button is displayed for each string in Items, and each string appears to the right of a radio button as the label of the button.

If the current value of a field associated with a radio group matches one of the strings in the Items property, that radio button is selected. For example, if three strings, "Red," "Yellow," and "Blue," are listed for Items, and the field for the current record contains the value "Blue," then the third button in the group appears selected.

Note: If the field does not match any strings in Items, a radio button may still be selected if the field matches a string in the Values property. If the field for the current record does not match any strings in Items or Values, no radio button is selected.

The Values property can contain an optional list of strings that can be returned to the dataset when a user selects a radio button and posts a record. Strings are associated with buttons in numeric sequence. The first string is associated with the first button, the second string with the second button, and so on. For example, suppose Items contains "Red," "Yellow," and "Blue," and Values contains "Magenta," "Yellow," and "Cyan." If a user selects the button labeled "Red," "Magenta" is posted to the database.

If strings for Values are not provided, the Item string for a selected radio button is returned to the database when a record is posted.

See Also