Difference between revisions of "TCheckGroup"

From Lazarus wiki
Jump to navigationJump to search
(Preparation for translation)
(→‎Usage: Small example added)
Line 17: Line 17:
 
====Small example====
 
====Small example====
  
'''in progress --[[User:Michl|Michl]] 23:54, 31 July 2014 (CEST)'''
+
It changes the background color of a form. This color is determined by adding the individual color components:
  
 +
* create a new application and place a TCheckGroup on your form
 +
* in the object inspector change the property ''Name'' of ''CheckGroup1'' to ''cgRed'' and the caption to ''Red''
 +
* add the checkboxes for ''cgRed'':
 +
** in the object inspector select the property ''Items'' of ''cgRed''
 +
** click on the button [...], the character chain editor opens
 +
** write among one another ''1 2 4 8 16 32 64 128'' and complete the entry with the ''OK'' button
 +
* copy this TCheckGroup by right click ''cgRed'' in the form and click on ''Copy''
 +
* right-click the form and click on ''Insert'', which creates TCheckGroup named ''cgRed1''
 +
* now change the ''Name'' of ''cgRed1'' to ''cgGreen'' and the ''Caption'' to ''Green''
 +
* insert even a TCheckGroup and change the name to ''cgBlue'' and the caption to ''Blue''
 +
* whenever a CheckBox is clicked, the color will change:
 +
** in the object inspector create the ''OnItemClick'' event handler of ''cgRed'' by clicking the button [...] next to the event ''OnItemClick''
 +
** select for ''cgGreen'' and ''cgBlue'' also this event handler, by choosing each next to the event ''OnItemClick'' ComboBox ''cgRedItemClick''
 +
** write following code in the event handler:
 +
<syntaxhighlight>
 +
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;
 +
</syntaxhighlight>
 +
* start your program, it could look like:
 +
 +
[[image:ExampleTCheckGroup.png]]
  
 
==See also==
 
==See also==

Revision as of 19:30, 4 August 2014

Deutsch (de) English (en) suomi (fi) français (fr) 日本語 (ja) русский (ru) 中文(中国大陆)‎ (zh_CN)

>> LCL Components >> TCheckGroup

This page explains how to use the TCheckGroup component. When I mention to click on something, unless I explicitly say to right-click, you always left-click on the item in question.

Description

A group of Check Boxes physically and logically grouped together on a form

Comp Standard TCheckGroup.png

Usage

To use a TCheckGroup on a form, you can simply select it on the Standard component pallet 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:

  • create a new application and place a TCheckGroup on your form
  • in the object inspector change the property Name of CheckGroup1 to cgRed and the caption to Red
  • add the checkboxes for cgRed:
    • in the object inspector select the property Items of cgRed
    • click on the button [...], the character chain editor opens
    • write among one another 1 2 4 8 16 32 64 128 and complete the entry with the OK button
  • copy this TCheckGroup by right click cgRed in the form and click on Copy
  • right-click the form and click on Insert, which creates TCheckGroup named cgRed1
  • now change the Name of cgRed1 to cgGreen and the Caption to Green
  • insert even a TCheckGroup and change the name to cgBlue and the caption to Blue
  • whenever a CheckBox is clicked, the color will change:
    • in the object inspector create the OnItemClick event handler of cgRed by clicking the button [...] next to the event OnItemClick
    • select for cgGreen and cgBlue also this event handler, by choosing each next to the event OnItemClick ComboBox cgRedItemClick
    • write following code in the event handler:
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;
  • start your program, it could look like:

ExampleTCheckGroup.png

See also

TCheckBox
TGroupBox


Return To: LCL Components  — Previous: TRadioGroup Next: TPanel


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