Sign in Join
Wiki copytemporary

TGroupBox: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: TGroupBox

OldNewLine
1+A **TGroupBox** ![](/wiki-images/b/b8/Tgroupbox.png) is a container that allows a number of objects to be grouped physically and conceptually on a [[TForm|form]].
2+
3+## Usage
4+
5+To use a [[doc:lcl/stdctrls/tgroupbox.html|TGroupBox]] on a form, you can simply select it on the [[Standard tab]] of the [[Component Palette]] and place it by clicking on the form.
6+
7+## Small example
8+
9+- create a new application and place two TGroupBoxes on your form
10+- in GroupBox1 insert a [[TButton]] *Button1* and in GroupBox2 TButton *Button2*
11+- put on your form (outside of the groupboxes) two [[TRadioButton]]
12+- change in the [[IDE Window: Object Inspector|object Inspector]] the caption of RadioButton1 to *User* and of RadioButton2 to *Administrator*
13+- change the [[Property|property]] *Checked* of RadioButton2 to *[[True]]*
14+- create the *OnChange* [[Event handler|event handler]] of RadioButton1 by double clicking *RadioButton1*
15+- use this handler also for RadioButton2
16+ - choose in the object Inspector ''RadioButton2'
17+ - now select the tab *Events* in the object Inspector
18+ - go to the event *OnChange* and select in the adjacent combobox *RadioButton1Change*
19+- make *GroupBox2* for user invisible by choosing in the RadioButton
20+ - write following line in the event handler of the RadioButtons in the source editor:
21+
22+``` Pascal
23+procedure TForm1.RadioButton1Change(Sender: TObject);
24+begin
25+ GroupBox2.Visible:=Radiobutton2.Checked;
26+end;
27+```
28+
29+- add still the event handler of the buttons and add some code like:
30+
31+``` Pascal
32+procedure TForm1.Button1Click(Sender: TObject);
33+begin
34+ ShowMessage('User and administrator can click this button');
35+end;
36+
37+procedure TForm1.Button2Click(Sender: TObject);
38+begin
39+ ShowMessage('Only administrator can click this button');
40+end;
41+```
42+
43+- it shows in the [[Dialog Examples|ShowMessage dialog]] who can press the button
44+- start your program, it could look like:
45+
46+![](/wiki-images/9/9a/ExampleTGroupBox1.png) -\> ![](/wiki-images/f/f3/ExampleTGroupBox2.png)
47+
48+## See also
49+
50+- [[doc:lcl/stdctrls/tgroupbox.html|TGroupBox doc]]
51+- [[TPairSplitter]]
52+- [[TNotebook]]
53+- [[TPageControl]]
54+- [[TTabControl]]
55+
56+---
57+*From the Free Pascal wiki, page "TGroupBox", as it stood on 2019-09-15 after a change by Djzepi, 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](/wiki-contact).*

Back to history