Table of Contents

Items and Selection

TTMSFNCCheckGroup displays a set of check boxes and stores the checked state in Value. Use it when users can select more than one option and the application needs a compact bit-mask representation.

Check group with multiple options

Configure Items

Add entries to Items for each option. Item text can use the same HTML-capable rendering as other FNC controls, which is useful for emphasis or small status labels.

TMSFNCCheckGroup1.Items.Clear;
TMSFNCCheckGroup1.Items.Add('Email');
TMSFNCCheckGroup1.Items.Add('<b>SMS</b>');
TMSFNCCheckGroup1.Items.Add('In-app message');
TMSFNCCheckGroup1.Value := 3;
TMSFNCCheckGroup1.OnCheckBoxClick := TMSFNCCheckGroup1CheckBoxClick;

React to Selection Changes

Handle OnCheckBoxClick when the application needs the changed item index and the current Value mask. Store the mask when the selected options must be restored later.

procedure TForm1.TMSFNCCheckGroup1CheckBoxClick(Sender: TObject; AItemIndex: Integer; AValue: Int64);
begin
  Caption := 'Changed item ' + AItemIndex.ToString + ', mask ' + AValue.ToString;
end;

Use the Picker Variant

TTMSFNCCheckGroupPicker presents the same multi-select model in a drop-down editor. Set Items, Value, Separator, and the drop-down size to make the selected values readable without taking permanent form space.

TMSFNCCheckGroupPicker1.Items.Clear;
TMSFNCCheckGroupPicker1.Items.Add('Create');
TMSFNCCheckGroupPicker1.Items.Add('Update');
TMSFNCCheckGroupPicker1.Items.Add('Delete');
TMSFNCCheckGroupPicker1.Value := 1;
TMSFNCCheckGroupPicker1.Separator := ', ';
TMSFNCCheckGroupPicker1.DropDownWidth := 220;
TMSFNCCheckGroupPicker1.DropDownHeight := 180;
TMSFNCCheckGroupPicker1.CloseOnSelection := False;

Combining item configuration, selection events, and the picker variant

Configure items, react to changes, and expose the same selection through a picker for a compact form layout:

procedure TForm1.FormCreate(Sender: TObject);
begin
  TMSFNCCheckGroup1.Items.Add.Text := 'Option A';
  TMSFNCCheckGroup1.Items.Add.Text := 'Option B';
  TMSFNCCheckGroup1.Items.Add.Text := 'Option C';
  TMSFNCCheckGroup1.Value := 3; // pre-check A and B (bits 0 and 1)

  // Mirror items and initial value in the picker
  TMSFNCCheckGroupPicker1.Items.Add.Text := 'Option A';
  TMSFNCCheckGroupPicker1.Items.Add.Text := 'Option B';
  TMSFNCCheckGroupPicker1.Items.Add.Text := 'Option C';
  TMSFNCCheckGroupPicker1.Value := TMSFNCCheckGroup1.Value;
end;

procedure TForm1.TMSFNCCheckGroup1CheckBoxClick(Sender: TObject;
  AIndex: Integer; AValue: Integer);
begin
  TMSFNCCheckGroupPicker1.Value := AValue; // keep picker in sync
end;

See Also