Skip to main content

Example: TreeList.Items

  • 2 minutes to read

The following sample demonstrates how to implement the functionality of a radio group using check box in-place editors. The ExtendedRadioButtonCheck method accepts the following parameters:

ATreeList represents the tree list control.

ANode represents a node within the control.

AItemIndex represents the index of a column containing Boolean values.

The method uses the Items property to iterate through the collection of nodes within the tree list control.

The example assumes that your tree list control has a column with check boxes assigned as in-place editors. When the end-user checks a check box within the column, all other check boxes get unchecked automatically. This behavior fakes the behavior of a radio group control. Alternatively, you can use the built-in radio group functionality.

procedure ExtendedRadioButtonCheck(ATreeList: TcxTreeList; ANode: TcxTreeListNode; AItemIndex: Integer);
var
  I: Integer;
begin
  ATreeList.BeginUpdate;
  try
    for I := 0 to ATreeList.Count - 1 do
      if ATreeList.Items[I] = ANode then
        ATreeList.Items[I].Values[AItemIndex] := True
      else
        ATreeList.Items[I].Values[AItemIndex] := False;
    end;
  finally
    ATreeList.EndUpdate;
  end;
end;