TLabel/fr: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: TLabel/fr
| Old | New | Line | |
|---|---|---|---|
| 1 | + | **TLabel**  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/fr|TGraphicControl]] et est disponible dans l'[[Standard tab/fr|onglet Standard]] de la [[Component Palette/fr|palette de composants]]. | |
| 2 | + | ||
| 3 | + | # Emploi | |
| 4 | + | ||
| 5 | + | Il s'agit de l'un des composants les plus basiques qui puissent être utilisés sur une [[TForm/fr|fiche]]. La plupart des étiquettes sont le marquage d'autres composants, tels que des [[TEdit/fr|champs d'édition]], des [[TMemo/fr|mémos]], des [[TStringGrid/fr|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). | |
| 6 | + | ||
| 7 | + | Vous pouvez ajouter un TLabel sur votre fiche en cliquant sur  dans la palette de composant et le placer avec un clic sur votre fiche. | |
| 8 | + | ||
| 9 | + | Pour modifier l'intitulé (*caption*) par défaut d'un TLabel nouvellement ajouté sur une fiche, vous pouvez procéder de la sorte : | |
| 10 | + | ||
| 11 | + | - Sur votre fiche avec un clic, sélectionnez le TLabel. | |
| 12 | + | - 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. | |
| 13 | + | - De la même manière, vous pouvez changer le nom du composant pour lui en donner un plus parlant. | |
| 14 | + | ||
| 15 | + | # Modifier l'intitulé à l'exécution | |
| 16 | + | ||
| 17 | + | Bien sûr, vous pouvez changer l'intitulé (le texte affiché) à l'exécution. L'exemple suivant montre comment : | |
| 18 | + | ||
| 19 | + | - Créez une nouvelle [[Form Tutorial/fr|application IHM]] avec la fiche *Form1*. Ajoutez à cette fiche un [[TButton/fr|bouton]] *Button1* et une étiquette *Label1* en sélectionnant les composants appropriés de la palette de composants et en cliquant sur *Form1* (l'étiquette devrait être au dessus du bouton). | |
| 20 | + | - Créez maintenant un [[Event order/fr|gestionnaire d'événement]] pour *Button1* en double-cliquant simplement sur *Button1* (car c'est l'événement par défaut i.e. le plus prévisible/usité). | |
| 21 | + | - Insérez le code suivant dans le gestionnaire du OnClick du *Button1* : | |
| 22 | + | ||
| 23 | + | ``` pascal | |
| 24 | + | procedure TForm1.Button1Click(Sender: TObject); | |
| 25 | + | const Cnt: Integer = 0; //Counter to determine how many times the button has been clicked | |
| 26 | + | begin | |
| 27 | + | inc(Cnt); //Increment the counter by 1 | |
| 28 | + | Label1.Caption:='Button was clicked ' + //Write the text on the caption of Label1 | |
| 29 | + | IntToStr(Cnt) + ' times'; | |
| 30 | + | end; | |
| 31 | + | ``` | |
| 32 | + | ||
| 33 | + | - Démarrez votre programme et testez le changement de l'étiquette en cliquant sur le bouton. | |
| 34 | + | ||
| 35 | + | # Emploi en commentaires | |
| 36 | + | ||
| 37 | + | Pour représenter un texte multi-ligne, vous avez besoin d'insérer au bon endroit dans la chaîne des *[[End of Line/fr|fins de ligne]]* comme signal de rupture. Exemple: | |
| 38 | + | ||
| 39 | + | ``` pascal | |
| 40 | + | Label1.Caption := 'This' + LineEnding + 'is' + LineEnding + 'a' + LineEnding + 'multiline' + LineEnding + 'text'; | |
| 41 | + | ``` | |
| 42 | + | ||
| 43 | + | # Voir aussi | |
| 44 | + | ||
| 45 | + | - [[doc:/lcl/stdctrls/tlabel.html|Doc. TLabel]] | |
| 46 | + | - [[TStaticText/fr|TStaticText]] | |
| 47 | + | ||
| 48 | + | --- | |
| 49 | + | *From the Free Pascal wiki, page "TLabel/fr", as it stood on 2020-03-01 after a change by GAN, 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).* |
