CalculateCheckStates(TcxEditValue,IcxCheckItems,TcxCheckStatesValueFormat,TcxCheckStates) Method
Calculates check box states for the specified edit value.
Declaration
function CalculateCheckStates(const AValue: TcxEditValue; AItems: IcxCheckItems; AValueFormat: TcxCheckStatesValueFormat; var ACheckStates: TcxCheckStates): Boolean;
Parameters
| Name | Type | Description |
|---|---|---|
| AValue | TcxEditValue | The source edit value. |
| AItems | IcxCheckItems | Check box items of the source editor with multiple check boxes, for example, the Properties.Items property of a TcxCheckGroup editor. |
| AValueFormat | TcxCheckStatesValueFormat | The check box state value format. This parameter value specifies how the function interprets source edit value ( |
| ACheckStates | TcxCheckStates | This var parameter returns the calculated array of check box states. |
Returns
| Type | Description |
|---|---|
| Boolean |
|
Remarks
You can call CalculateCheckStates and CalculateCheckStatesValue global functions to convert a combination of individual check box states into an edit value and vice versa. These operations can be useful for scenarios that involve interaction between editors with multiple check boxes (such as check groups and check combo boxes) and dataset fields.
Code Example: Read All Check Combo Box States
The following code example uses the TcxCustomCheckComboBox.Value property value to list all checked/unchecked item states in a TcxMemo editor:
uses
cxCheckBox, // Declares the CalculateCheckStates global function
cxCheckComboBox; // Declares the TcxCheckComboBox class and related types
//...
procedure TMyForm.cxButton1Click(Sender: TObject);
var
AProperties: TcxCheckComboBoxProperties;
AValue: Variant;
ACheckStates: TcxCheckStates;
I: Integer;
begin
AValue := cxCheckComboBox1.Value;
AProperties := cxCheckComboBox1.Properties;
CalculateCheckStates(AValue, AProperties.Items, AProperties.EditValueFormat, ACheckStates);
cxMemo1.Clear;
for I := 0 to Length(ACheckStates) - 1 do
if ACheckStates[I] = cbsChecked then
cxMemo1.Lines.Add('Checked');
else
cxMemo1.Lines.Add('Unchecked');
end;