TLabel/fr

From Lazarus wiki
Revision as of 10:24, 12 August 2017 by E-ric (talk | contribs) (Created page with "{{TLabel}} '''TLabel''' image:tlabel.png est un composant qui crée un texte avec une ou plusieurs lignes sur une fiche ou un cadre. Un TLabel est un descendant de TGra...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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

TLabel tlabel.png est un composant qui crée un texte avec une ou plusieurs lignes sur une fiche ou un cadre. Un TLabel est un descendant de TGraphicControl et est disponible dans l'onglet Standard de la palette de composants.

Emploi

Il s'agit de l'un des composants les plus basiques qui puissent être utilisés sur une fiche. La plupart des étiquettes sont le marquage d'autres composants, tels que des champs d'édition, des mémos, des grilles et ainsi de suite. TLabel propose un certain nombre d'événements le plus souvent inutilisés (car on agit rarement sur un TLabel).

Vous pouvez ajouter un TLabel sur votre fiche en cliquant sur tlabel.png dans la palette de composant et le placer avec un clic sur votre fiche.

Pour modifier l'intitulé (caption) par défaut d'un TLabel nouvellement ajouté sur une fiche, vous pouvez procéder de la sorte :

  • Sur votre fiche avec un clic, sélectionnez le TLabel.
  • Depuis l'onglet Propriétés de l'inspecteur d'objet, sélectionnez la propriété Caption et changez-là dans le champ d'édition à droite.
  • De la même manière, vous pouvez changer le nom du composant pour lui en donner plus parlant.

Modifier l'intitulé à l'exécution

Bien sûr, vous pouvez changer l'intitulé (le texet affiché) à l'exécution. L'exemple suivant montre comment :

  • Créez une nouvelle application IHM avec la fiche Form1. Ajoutez à cette fiche un bouton Button1 et une étiquette Label1 en sélectionnant les composants appropriés de la palette de composantset en cliquant sur Form1 (l'étiquette devrait être au dessus du bouton).
  • Créez maintenant un gestionnaire d'événement pour Button1 en double-cliquant simplement sur Button1 (c'est l'événement par défaut car le plus usité).
  • Insérez le code suivant dans le gestionnaire du OnClick du Button1 :
procedure TForm1.Button1Click(Sender: TObject);
const Cnt: Integer = 0;                     //Counter to determine how many times the button has been clicked
begin
  inc(Cnt);                                 //Increment the counter by 1
  Label1.Caption:='Button was clicked ' +   //Write the text on the caption of Label1
    IntToStr(Cnt) + ' times';
end;
  • Démarrez votre programme et testez le changement de l'étiquette en cliquanrt sur le bouton.

Commentaires

Pour représenter un texte multi-ligne, vous avez besoin d'insérer au bon endroit dans la chaîne des fins de ligne To represent a multiline text, you need to insert at the appropriate place in the string a LineEnding signal de rupture. Exemple:

Label1.Caption := 'This' + LineEnding + 'is' + LineEnding + 'a' + LineEnding + 'multiline' + LineEnding + 'text';

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