Sign in Join
Wiki copytemporary

TLabel/ja

Deutsch · English · Français · Suomi · Русский · 日本語

TLabel は1、あるいは複数行のテキストアイテムを他のコンポーネントに作るコンポーネントである。TLabelはTGraphicControlより派生し、コンポーネントパレットのStandardタブより利用できる。

使い方

TLabelはformsで用いることのできるもっとも基本的なコンポーネントの1つである。ほとんどのラベルは、例えば、Edit fields、Memos、StringGridsなどといった他のコンポーネントのマーキングである。TLabelは様々な利用可能なイベントをもたらすが、ほとんどの場合必要とされない。

StandardコンポーネントのTLabel(テキストシンボルAbc)をクリックすることにより、フォームにラベルを加えることができ、フォーム上にクリックして配置することができる。

フォームに新しく挿入された、デフォルトラベルLabelを変更するために、以下のように進めることができる:

実行時にキャプションを変更する

もちろん、実行中にキャプション(表示されるテキスト)を変えることができる。

以下の例はこれを示している:

pascal
procedure TForm1.Button1Click(Sender: TObject);
const Cnt: Integer = 0;                     //何回ボタンがクリックされたか決めるカウンタ
begin
  inc(Cnt);                                 //カウンタを1インクリメント
  Label1.Caption:='Button was clicked ' +   //Label1のキャプションにテキストをを書き込む
    IntToStr(Cnt) + ' times';
end;

右揃えしたラベルのDelphiとの非互換性

コメント

複数行のテキストを表すため、行の折り返しの目印として、ふさわしい場所にLineEndingを配置することができる。

例:

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

以下も参照のこと


From the Free Pascal wiki, page "TLabel/ja", as it stood on 2024-03-20 after a change by Ariben, 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.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.