
The group component is used to group together a number of controls so that they can be handled as a group, for example displayed or hidden as the need arises (similar to the Panel component). They can also be used to group logically similar items such as a group of check boxes (unlike the Radio Group there is no special control for check box groups).
Example:


procedure TForm1.Button2Click(Sender: TObject);
begin
GroupBox1.visible:=true;
end;
procedure TForm1.CheckBox4Click(Sender: TObject);
begin
if Checkbox4.Checked then
begin
display_string := display_string + 'Bananas ';
Edit2.Text:=display_string;
end;
end;
This example is similar to that above but deals with the vexed question of extra pizza toppings - just what should you order? Here is a form that might be used to make choices:

When the user click on an option a string should be displayed in the EditBox and the Memo to remind the customer what she has ordered. This can be coded as follows:
procedure TForm1.CheckBox2Click(Sender: TObject);
begin
if CheckBox2.Checked then
begin
extra_toppings_string:= extra_toppings_string+ 'mushrooms ';
edit1.Text:='';
edit1.text:=extra_toppings_string;
memo1.Clear;
memo1.Lines.Add(extra_toppings_string);
end
end;
There is a similar block of code for the other CheckBoxes. But what if the customer changes her mind? This code does not allow for removal of items if a CheckiBox is unchecked. Here is an amended version of the code:
If a CheckBox is unchecked the display string is set to nothing and the other CheckBoxes are examined to see if they are checked or unchecked. If they are checked then their item is added to a new version of the display string, otherwise their item is not added. This code should be included in the procedure for each CheckBox, with a slight variation for each one as a different set of CheckBoxes is consulted for each one.
Here is the code for CheckBox4 (anchovies):
procedure TForm1.CheckBox4Click(Sender: TObject);
begin
if CheckBox4.Checked then
begin
extra_toppings_string:= extra_toppings_string+ 'anchovies ';
edit1.Text:='';
edit1.text:=extra_toppings_string;
memo1.Clear;
memo1.Lines.Add(extra_toppings_string);
end
else
if not (Checkbox4.Checked) then
begin
extra_toppings_string:= ' ';
if checkbox2.Checked then extra_toppings_string:=extra_toppings_string+'mushrooms
'
else extra_toppings_string:=extra_toppings_string+' ';
if checkbox3.Checked then extra_toppings_string:=extra_toppings_string+'olives
'
else extra_toppings_string:=extra_toppings_string+' ';
if checkbox5.Checked then extra_toppings_string:=extra_toppings_string+'Gorgonzola
'
else extra_toppings_string:=extra_toppings_string+' ';
edit1.Text:='';
edit1.text:=extra_toppings_string;
memo1.Clear;
memo1.Lines.Add(extra_toppings_string);
end
end;
This code processes CheckBoxes 2,3 and 5.