Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

CalculateCheckStates(TcxEditValue,IcxCheckItems,TcxCheckStatesValueFormat,TcxCheckStates) Method

Calculates check box states for the specified edit value.

#Declaration

Delphi
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 (AValue) and check box items (AItems).

ACheckStates TcxCheckStates

This var parameter returns the calculated array of check box states.

#Returns

Type Description
Boolean

True if the check box state calculation is successful; otherwise, False.

#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: Get All Check Combo Box States

The following code example lists all states of an in-place TcxCheckComboBox editor in a TcxMemo editor:

uses
..., cxCheckBox;  // This unit contains the CalculateCheckStates function declaration
//...
procedure TMyForm.cxButton1Click(Sender: TObject);
var
  AProperties: TcxCheckComboBoxProperties;
  AValue: TcxEditValue;
  ACheckStates: TcxCheckStates;
  I: Integer;
begin
  AValue := cxBarEditItem1.EditValue;
  AProperties := cxBarEditItem1.Properties as TcxCheckComboBoxProperties;
  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;
See Also