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

TcxCustomCheckComboBox.GetItemState(Integer) Method

Returns the check state of an item.

#Declaration

Delphi
function GetItemState(AIndex: Integer): TcxCheckBoxState;

#Parameters

Name Type
AIndex Integer

#Returns

Type
TcxCheckBoxState

#Remarks

The GetItemState function returns the state (checked or unchecked) of the specified item. The item is addressed by the AIndex parameter, providing its position within the Properties.Items collection.

You can set the item’s state using the SetItemState method.

The Value property stores states of all items. Each bit in this value corresponds to the state of a specific item.

Suppose you need to delete selected entries from your media library. A check combo box is used to represent all the artists in your collection. The end-user can select items no longer required (note that you can prevent individual items from being deleted by setting their Enabled state to False). The following screenshot shows a check combo box with two items selected.

Now the user can press, say, a Delete button, to initiate the deletions. Your code for such an action may look like the following:

Delphi
procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
begin
  with cxCheckComboBox1 do
  begin
    for I := Pred(Properties.Items.Count) downto 0 do
      if GetItemState(I) = cbsChecked then
      begin
        { some action }
        Properties.Items.Delete(I);
      end;
    Value := 0;
  end;
end;

Note

As with all similar operations performing indexed deletions, the collection needs to be traversed in reverse order.

See Also