Difference between revisions of "TGroupBox"

From Free Pascal wiki
Jump to navigationJump to search
m (Preparation for translation)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{TGroupBox}}
 
  
>> [[LCL Components]] >> TGroupBox<br/>
 
  
This page explains how to use the [[doc:lcl/stdctrls/tgroupbox.html|TGroupBox]] component. When I mention to click on something, unless I explicitly say to right-click, you always left-click on the item in question.
+
{{TGroupBox}}
  
==Description==
+
A '''TGroupBox''' [[image:tgroupbox.png]] is a container that allows a number of objects to be grouped physically and conceptually on a [[TForm|form]].
  
A container that allows a number of objects to be grouped physically and conceptually on a form.
+
==Usage==
 
+
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.
[[image:Comp_Standard_TGroupBox.png]]
 
  
==Usage==
+
==Small example==
 +
* create a new application and place two TGroupBoxes on your form
 +
* in GroupBox1 insert a [[TButton]] ''Button1'' and in GroupBox2 TButton ''Button2''
 +
* put on your form (outside of the groupboxes) two [[TRadioButton]]
 +
* change in the [[IDE_Window:_Object_Inspector|object Inspector]] the caption of RadioButton1 to ''User'' and of RadioButton2 to ''Administrator''
 +
* change the [[Property|property]] ''Checked'' of RadioButton2 to ''[[True]]''
 +
* create the ''OnChange'' [[Event handler|event handler]] of RadioButton1 by double clicking ''RadioButton1''
 +
* use this handler also for RadioButton2
 +
** choose in the object Inspector ''RadioButton2'
 +
** now select the tab ''Events'' in the object Inspector
 +
** go to the event ''OnChange'' and select in the adjacent combobox ''RadioButton1Change''
 +
* make ''GroupBox2'' for user invisible by choosing in the RadioButton
 +
** write following line in the event handler of the RadioButtons in the source editor:
 +
<syntaxhighlight lang="Pascal">
 +
procedure TForm1.RadioButton1Change(Sender: TObject);
 +
begin
 +
  GroupBox2.Visible:=Radiobutton2.Checked;
 +
end;
 +
</syntaxhighlight>
 +
* add still the event handler of the buttons and add some code like:
 +
<syntaxhighlight lang="Pascal">
 +
procedure TForm1.Button1Click(Sender: TObject);
 +
begin
 +
  ShowMessage('User and administrator can click this button');
 +
end;
  
'''under construction --[[User:Michl|Michl]] 08:53, 25 June 2014 (CEST)''''
+
procedure TForm1.Button2Click(Sender: TObject);
 +
begin
 +
  ShowMessage('Only administrator can click this button');
 +
end;
 +
</syntaxhighlight>
 +
* it shows in the [[Dialog_Examples#ShowMessage|ShowMessage dialog]] who can press the button
 +
* start your program, it could look like:
  
 +
[[image:ExampleTGroupBox1.png]] -> [[image:ExampleTGroupBox2.png]]
  
 +
==See also==
 +
* [[doc:lcl/stdctrls/tgroupbox.html|TGroupBox doc]]
 +
* [[TPairSplitter]]
 +
* [[TNotebook]]
 +
* [[TPageControl]]
 +
* [[TTabControl]]
  
{{LCL Components Footer |TScrollBar|TRadioGroup}}
 
 
{{LCL Components}}
 
{{LCL Components}}
 
[[Category:LCL]]
 
[[Category:Components]]
 
--[[User:Michl|Michl]] 08:53, 25 June 2014 (CEST)
 

Latest revision as of 09:16, 15 September 2019


Deutsch (de) English (en) suomi (fi) français (fr) 日本語 (ja) русский (ru)

A TGroupBox tgroupbox.png is a container that allows a number of objects to be grouped physically and conceptually on a form.

Usage

To use a 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.

Small example

  • create a new application and place two TGroupBoxes on your form
  • in GroupBox1 insert a TButton Button1 and in GroupBox2 TButton Button2
  • put on your form (outside of the groupboxes) two TRadioButton
  • change in the object Inspector the caption of RadioButton1 to User and of RadioButton2 to Administrator
  • change the property Checked of RadioButton2 to True
  • create the OnChange event handler of RadioButton1 by double clicking RadioButton1
  • use this handler also for RadioButton2
    • choose in the object Inspector RadioButton2'
    • now select the tab Events in the object Inspector
    • go to the event OnChange and select in the adjacent combobox RadioButton1Change
  • make GroupBox2 for user invisible by choosing in the RadioButton
    • write following line in the event handler of the RadioButtons in the source editor:
procedure TForm1.RadioButton1Change(Sender: TObject);
begin
  GroupBox2.Visible:=Radiobutton2.Checked;
end;
  • add still the event handler of the buttons and add some code like:
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage('User and administrator can click this button');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  ShowMessage('Only administrator can click this button');
end;
  • it shows in the ShowMessage dialog who can press the button
  • start your program, it could look like:

ExampleTGroupBox1.png -> ExampleTGroupBox2.png

See also


LCL Components
Component Tab Components
Standard TMainMenu • TPopupMenu • TButton • TLabel • TEdit • TMemo • TToggleBox • TCheckBox • TRadioButton • TListBox • TComboBox • TScrollBar • TGroupBox • TRadioGroup • TCheckGroup • TPanel • TFrame • TActionList
Additional TBitBtn • TSpeedButton • TStaticText • TImage • TShape • TBevel • TPaintBox • TNotebook • TLabeledEdit • TSplitter • TTrayIcon • TControlBar • TFlowPanel • TMaskEdit • TCheckListBox • TScrollBox • TApplicationProperties • TStringGrid • TDrawGrid • TPairSplitter • TColorBox • TColorListBox • TValueListEditor
Common Controls TTrackBar • TProgressBar • TTreeView • TListView • TStatusBar • TToolBar • TCoolBar • TUpDown • TPageControl • TTabControl • THeaderControl • TImageList • TPopupNotifier • TDateTimePicker
Dialogs TOpenDialog • TSaveDialog • TSelectDirectoryDialog • TColorDialog • TFontDialog • TFindDialog • TReplaceDialog • TTaskDialog • TOpenPictureDialog • TSavePictureDialog • TCalendarDialog • TCalculatorDialog • TPrinterSetupDialog • TPrintDialog • TPageSetupDialog
Data Controls TDBNavigator • TDBText • TDBEdit • TDBMemo • TDBImage • TDBListBox • TDBLookupListBox • TDBComboBox • TDBLookupComboBox • TDBCheckBox • TDBRadioGroup • TDBCalendar • TDBGroupBox • TDBGrid • TDBDateTimePicker
Data Access TDataSource • TCSVDataSet • TSdfDataSet • TBufDataset • TFixedFormatDataSet • TDbf • TMemDataset
System TTimer • TIdleTimer • TLazComponentQueue • THTMLHelpDatabase • THTMLBrowserHelpViewer • TAsyncProcess • TProcessUTF8 • TProcess • TSimpleIPCClient • TSimpleIPCServer • TXMLConfig • TEventLog • TServiceManager • TCHMHelpDatabase • TLHelpConnector
Misc TColorButton • TSpinEdit • TFloatSpinEdit • TArrow • TCalendar • TEditButton • TFileNameEdit • TDirectoryEdit • TDateEdit • TTimeEdit • TCalcEdit • TFileListBox • TFilterComboBox • TComboBoxEx • TCheckComboBox • TButtonPanel • TShellTreeView • TShellListView • TXMLPropStorage • TINIPropStorage • TJSONPropStorage • TIDEDialogLayoutStorage • TMRUManager • TStrHolder
LazControls TCheckBoxThemed • TDividerBevel • TExtendedNotebook • TListFilterEdit • TListViewFilterEdit • TLvlGraphControl • TShortPathEdit • TSpinEditEx • TFloatSpinEditEx • TTreeFilterEdit • TExtendedTabControl •
RTTI TTIEdit • TTIComboBox • TTIButton • TTICheckBox • TTILabel • TTIGroupBox • TTIRadioGroup • TTICheckGroup • TTICheckListBox • TTIListBox • TTIMemo • TTICalendar • TTIImage • TTIFloatSpinEdit • TTISpinEdit • TTITrackBar • TTIProgressBar • TTIMaskEdit • TTIColorButton • TMultiPropertyLink • TTIPropertyGrid • TTIGrid
SQLdb TSQLQuery • TSQLTransaction • TSQLScript • TSQLConnector • TMSSQLConnection • TSybaseConnection • TPQConnection • TPQTEventMonitor • TOracleConnection • TODBCConnection • TMySQL40Connection • TMySQL41Connection • TMySQL50Connection • TMySQL51Connection • TMySQL55Connection • TMySQL56Connection • TMySQL57Connection • TSQLite3Connection • TIBConnection • TFBAdmin • TFBEventMonitor • TSQLDBLibraryLoader
Pascal Script TPSScript • TPSScriptDebugger • TPSDllPlugin • TPSImport_Classes • TPSImport_DateUtils • TPSImport_ComObj • TPSImport_DB • TPSImport_Forms • TPSImport_Controls • TPSImport_StdCtrls • TPSCustomPlugin
SynEdit TSynEdit • TSynCompletion • TSynAutoComplete • TSynMacroRecorder • TSynExporterHTML • TSynPluginSyncroEdit • TSynPasSyn • TSynFreePascalSyn • TSynCppSyn • TSynJavaSyn • TSynPerlSyn • TSynHTMLSyn • TSynXMLSyn • TSynLFMSyn • TSynDiffSyn • TSynUNIXShellScriptSyn • TSynCssSyn • TSynPHPSyn • TSynTeXSyn • TSynSQLSyn • TSynPythonSyn • TSynVBSyn • TSynAnySyn • TSynMultiSyn • TSynBatSyn • TSynIniSyn • TSynPoSyn
Chart TChart • TListChartSource • TRandomChartSource • TUserDefinedChartSource • TCalculatedChartSource • TDbChartSource • TChartToolset • TChartAxisTransformations • TChartStyles • TChartLegendPanel • TChartNavScrollBar • TChartNavPanel • TIntervalChartSource • TDateTimeIntervalChartSource • TChartListBox • TChartExtentLink • TChartImageList
IPro TIpFileDataProvider • TIpHtmlDataProvider • TIpHttpDataProvider • TIpHtmlPanel
Virtual Controls TVirtualDrawTree • TVirtualStringTree • TVTHeaderPopupMenu