Delphi 之 標籤組件(TLabel組件)

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   使用   ar   for   

  標籤組件是比較常用的組件,現在來看看標籤組件的常用的基本屬性:

 

Align 

   它的作用是和表單對齊,對齊的方式有alNone, alTop, alBottom, alLeft, alRight, alClient, alCustom.

Alignment 

     它的作用是標籤文本顯示的位置,對齊為taLeftJustify, taRightJustify, taCenter意思為左邊,右邊,中間

autosize  

  自動調整標籤的大小。true為自動大小,flase為不改變大小。

FocusControl

  與某個控制項相關聯,通常與ShowAccelChar一起使用。當ShowAccelChar為True時,可以使用一個加速鍵,在標籤上使用&符號。此時Alt+快速鍵才有效果。

 

此時按下ALT+F鍵會切換文字框F,若按下ALT+G鍵會切換文字框G中

ShowAccelChar 

  該屬性確定True時,使用&符號時,文本上會顯示一個底線。

標籤的時間屬性

OnMouseEnter

  滑鼠移動到標籤上的事件。

OnClick

  按一下滑鼠事件

OnMouseLeave

  滑鼠離開事件

結合執行個體示範,當滑鼠移動到標籤上顯示底線。厲害底線消失。當按一下滑鼠擷取文字框焦點或按下快速鍵切換焦點。

 

unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls;type  TForm1 = class(TForm)    Label1: TLabel;    Label2: TLabel;    Edit1: TEdit;    Edit2: TEdit;    procedure FormCreate(Sender: TObject);    procedure Label1MouseEnter(Sender: TObject);    procedure Label1MouseLeave(Sender: TObject);    procedure Label1Click(Sender: TObject);    procedure Label2MouseEnter(Sender: TObject);    procedure Label2MouseLeave(Sender: TObject);    procedure Label2Click(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end;var  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);begin  Label1.Alignment:= taCenter;end;procedure TForm1.Label1MouseEnter(Sender: TObject);begin  (sender as TLabel).Font.Style:= [fsUnderline];end;procedure TForm1.Label1MouseLeave(Sender: TObject);begin  (Sender as TLabel).Font.Style:=[];end;procedure TForm1.Label1Click(Sender: TObject);begin  if(Sender as TLabel).Name = ‘Label1‘ then    Edit1.SetFocus  else    Edit2.SetFocus;end;procedure TForm1.Label2MouseEnter(Sender: TObject);begin  (Sender as TLabel).Font.Style:=[fsUnderline];end;procedure TForm1.Label2MouseLeave(Sender: TObject);begin  (Sender as TLabel).Font.Style:=[];end;procedure TForm1.Label2Click(Sender: TObject);begin  if(Sender as TLabel).Name = ‘Label2‘ then    Edit2.SetFocus  else    Edit1.SetFocus;end;end.

 

Delphi 之 標籤組件(TLabel組件)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.