Sign in Join
Wiki copytemporary

Revision 1 of 2, by Dbannon on 3-8-2022. The page as it is now.

TCheckGroup

A TCheckGroup is a control that comprises a group of TCheckBox items physically and logically grouped together on a container component.

Usage

To use a TCheckGroup on a form, you can simply select it on the Standard tab of the Component Palette and place it by clicking on the form.

Small example

It changes the background color of a form. This color is determined by adding the individual color components:

pascal
procedure TForm1.cgRedItemClick(Sender: TObject; Index: integer);
var
  i, c: Integer;
begin
  c := $000000;                                          // first the color is black
  for i:=0 to 7 do begin                                 // test Items 0..7 of all Checkgroups
    if cgRed.Checked[i]   then c := c + 1 shl i;         // amount of red   $000000..$0000FF
    if cgGreen.Checked[i] then c := c + 1 shl (i + 8);   // amount of green $000000..$00FF00
    if cgBlue.Checked[i]  then c := c + 1 shl (i + 16);  // amount of blue  $000000..$FF0000
  end;
  Color := c;
end;

<figure> <img src="ExampleTCheckGroup.png" title="ExampleTCheckGroup.png" /> <figcaption>ExampleTCheckGroup.png</figcaption> </figure>

Accessing the Check Boxes

Each item in the TCheckGroup has a Checked property, to set them all to checked do

pascal
for i := 0 to MyCheckGroup.items.Count-1 do   // check all the categories we found.
    MyCheckGroup.Checked[i] := true;

You can add items at run time by using TCheckGroup.Items, its a TStrings list. To add an new checkbox to the set, just do MyCheckGroup.Items.add('CheckThis'); Similarly, to remove all items, clear the list, MyCheckGroup.Items.clear;

See also


From the Free Pascal wiki, page "TCheckGroup", as it stood on 2022-03-08 after a change by Dbannon, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.