Difference between revisions of "TRadioGroup/fr"

From Free Pascal wiki
Jump to navigationJump to search
(Created page with "{{TRadioGroup}} Un '''TRadioGroup''' image:tradiogroup.png est un groupe de boutons radio associés mais mutuellement exclusifs demandant à l'utilisa...")
 
Line 7: Line 7:
  
 
== Petit exemple ==
 
== Petit exemple ==
Geometric figures should be drawn randomly and depending on the TRadioGroups to the form. RadioGroup1 determines the shape, the number RadioGroup2.
+
Les figures géométriques devraient être déssinées de manière aléatoire et selon le TRadioGroup de la fiche. RadioGroup1 détermine la forme, RadioGroup2 le nombre.
* create a new application and place two TRadioGroups on your form
+
* Créez une nouvelle application et placez deux TRadioGroups sur la fiche.
* change in the Object Inspector the property ''Name'' of ''RadioGroup1'' to ''rgShape'', also ''RadioGroup2'' to ''rgCount''
+
* modifiez dans l'inspecteur d'objet la propriété ''Name'' du ''RadioGroup1'' en ''rgShape'', et ''RadioGroup2'' en ''rgCount''.
* change identical ''Caption'' of ''rgShape'' to ''Shape'' and that of ''rgCount'' to ''Count''
+
* Modifiez en conséquence les intitulés Caption'' de ''rgShape'' en ''Shape'' et de ''rgCount'' en ''Count''.
* add the RadioButtons for ''rgShape'':
+
* Ajoutez les RadioButtons pour ''rgShape'':
** in the Object Inspector select the property ''Items'' of ''rgShape''
+
** dans l'inspecteur d'objet,; sélectionnez la propriété ''Items'' de ''rgShape''.
** click on the button [...], the character chain editor opens
+
** cliquez sur le bouton [...], ce qui ouvre l'éditeur de liste de chaînes
** write among each other ''Lines Rectangles Ellipses'' and complete the entry with the button ''OK''
+
** Ecrivez ''Lines Rectangles Ellipses'' et validez en cliquant sur le bouton ''OK''.
* add identical the RadioButtons for ''rgCount'' (written among each other): ''1 5 10 20 50 100''
+
* Ajoutez à l'identique les RadioButtons pour ''rgCount'' en écrivant : ''1 5 10 20 50 100''
* set the first RadioButton as the ''currently selected'', by setting the property ''ItemIndex'' of ''rgShape'' and ''rgCount'' from ''-1'' to ''0''
+
* Définissez le premier RadioButton comme le ''sélectionné en cours'' en mettant la propriété ''ItemIndex'' de ''rgShape'' et ''rgCount'' de ''-1'' à ''0''.
* create the ''OnClick'' event handler of ''rgShape'' by double clicking ''rgShape''
+
* Créez le gestionnaire de l'événement ''OnClick'' de ''rgShape'' en double-cliqnuant sur ce dernier.
* also use these event handler for ''rgCount'':
+
* Utilisez aussi ce gestionnaire pour ''rgCount'' :
** in the Object Inspector select ''rgCount''
+
** Dans l'inspecteur d'objet, sélectionnez ''rgCount''.
** now select the tab ''Events'' in the Object Inspector
+
** Maintenant sélectionnez l'onglet ''Events'' dans l'inspecteur d'objet.
** go to the ''OnClick'' event and select in the adjacent ComboBox ''rgShapeClick''
+
** Allez vers l'événement ''OnClick'' et sélectionnez dans la ComboBox adjacente ''rgShapeClick''
* whenever ''rgShape'' or ''rgCount'' is clicked, the form should be redrawn, therefore write following code in the event handler:
+
* à chaque fois que ''rgShape'' ou ''rgCount'' est cliquée, la fiche devrait être redessinée, aussi écrivez le code suivant dans le gestionnaire d'événement :
<source>
+
<syntaxhighlight>
 
procedure TForm1.rgShapeClick(Sender: TObject);
 
procedure TForm1.rgShapeClick(Sender: TObject);
 
begin
 
begin
 
   Repaint;
 
   Repaint;
 
end;  
 
end;  
</source>  
+
</syntaxhighlight>  
* whenever the form is redrawn, the shapes should be drawn:
+
* A chaque fois que la fiche est redessinée, les formes devraient être redessinées :
** in the Object Inspector select ''Form1''
+
** Dans l'inspecteur d'objet sélectionnez ''Form1''
** select the tab ''Events''
+
** sélectionnez l'onglet ''Evénements''
** click on the button [...] next to the event ''OnPaint''
+
** cliquez sur le bouton [...] en face de l'événement ''OnPaint''
** the handler is created, enter the following code:
+
** le gestionnaires est créé, entrez le code suivant :
<source>
+
<syntaxhighlight>
 
procedure TForm1.FormPaint(Sender: TObject);
 
procedure TForm1.FormPaint(Sender: TObject);
 
var
 
var
Line 50: Line 50:
 
     end;
 
     end;
 
end;
 
end;
</source>
+
</syntaxhighlight>
 
* démarrez votre programme, il pourrait ressembler à ceci :
 
* démarrez votre programme, il pourrait ressembler à ceci :
  
 
[[image:ExampleTRadioGroup.png]]
 
[[image:ExampleTRadioGroup.png]]
 +
Note : à chaque redessin, le résultat obtenu sera différent.
  
 
= Voir aussi =
 
= Voir aussi =

Revision as of 07:20, 23 August 2017

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

Un TRadioGroup tradiogroup.png est un groupe de boutons radio associés mais mutuellement exclusifs demandant à l'utilisateur de choisir l'une des alternatives proposées. C'est comme un TGroupBox avec des TRadioButtons intégrés.

Usage

Pour utiliser un TRadioGroup sur une fiche, vous pouvez simplement le sélectionner dans l'onglet Standard de la palette de composants et le placer sur la fiche.

Petit exemple

Les figures géométriques devraient être déssinées de manière aléatoire et selon le TRadioGroup de la fiche. RadioGroup1 détermine la forme, RadioGroup2 le nombre.

  • Créez une nouvelle application et placez deux TRadioGroups sur la fiche.
  • modifiez dans l'inspecteur d'objet la propriété Name du RadioGroup1 en rgShape, et RadioGroup2 en rgCount.
  • Modifiez en conséquence les intitulés Caption de rgShape en Shape et de rgCount en Count.
  • Ajoutez les RadioButtons pour rgShape:
    • dans l'inspecteur d'objet,; sélectionnez la propriété Items de rgShape.
    • cliquez sur le bouton [...], ce qui ouvre l'éditeur de liste de chaînes
    • Ecrivez Lines Rectangles Ellipses et validez en cliquant sur le bouton OK.
  • Ajoutez à l'identique les RadioButtons pour rgCount en écrivant : 1 5 10 20 50 100
  • Définissez le premier RadioButton comme le sélectionné en cours en mettant la propriété ItemIndex de rgShape et rgCount de -1 à 0.
  • Créez le gestionnaire de l'événement OnClick de rgShape en double-cliqnuant sur ce dernier.
  • Utilisez aussi ce gestionnaire pour rgCount :
    • Dans l'inspecteur d'objet, sélectionnez rgCount.
    • Maintenant sélectionnez l'onglet Events dans l'inspecteur d'objet.
    • Allez vers l'événement OnClick et sélectionnez dans la ComboBox adjacente rgShapeClick
  • à chaque fois que rgShape ou rgCount est cliquée, la fiche devrait être redessinée, aussi écrivez le code suivant dans le gestionnaire d'événement :
procedure TForm1.rgShapeClick(Sender: TObject);
begin
  Repaint;
end;
  • A chaque fois que la fiche est redessinée, les formes devraient être redessinées :
    • Dans l'inspecteur d'objet sélectionnez Form1
    • sélectionnez l'onglet Evénements
    • cliquez sur le bouton [...] en face de l'événement OnPaint
    • le gestionnaires est créé, entrez le code suivant :
procedure TForm1.FormPaint(Sender: TObject);
var
  i: Integer;
begin
  if TryStrToInt(rgCount.Items[rgCount.ItemIndex], i) then
    for i:=1 to i do begin
      Canvas.Pen.Color:=Random($1000000);
      Canvas.Brush.Color:=Random($1000000);
      case rgShape.Items[rgShape.ItemIndex] of
        'Lines':      Canvas.Line(Random(ClientWidth), Random(ClientHeight), Random(ClientWidth), Random(ClientHeight));
        'Rectangles': Canvas.Rectangle(Random(ClientWidth), Random(ClientHeight), Random(ClientWidth), Random(ClientHeight));
        'Ellipses':   Canvas.Ellipse(Random(ClientWidth), Random(ClientHeight), Random(ClientWidth), Random(ClientHeight));
      end;
    end;
end;
  • démarrez votre programme, il pourrait ressembler à ceci :

ExampleTRadioGroup.png Note : à chaque redessin, le résultat obtenu sera différent.

Voir aussi


Composant LCL
Onglet de palette Composants
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 • TOpenPictureDialog • TSavePictureDialog • TCalendarDialog • TCalculatorDialog • TPrinterSetupDialog • TPrintDialog • TPageSetupDialog • TTaskDialog
Data Controls TDBNavigator • TDBText • TDBEdit • TDBMemo • TDBImage • TDBListBox • TDBLookupListBox • TDBComboBox • TDBLookupComboBox • TDBCheckBox • TDBRadioGroup • TDBCalendar • TDBGroupBox • TDBGrid • TDBDateTimePicker
Data Access TDataSource • TBufDataset • TMemDataset • TSdfDataSet • TFixedFormatDataSet • TDbf
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 • TIDEDialogLayoutStorage • TMRUManager • TStrHolder
LazControls TCheckBoxThemed • TDividerBevel • TExtendedNotebook • TListFilterEdit • TListViewFilterEdit • TTreeFilterEdit • TShortPathEdit • TLvlGraphControl
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 • 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 • TIpHttpDataProvider • TIpHtmlPanel