RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TLabel.ShowAccelChar Property

Determines how an ampersand in the label text is displayed.

Pascal
property ShowAccelChar: Boolean;
C++
__property Boolean ShowAccelChar;

Set ShowAccelChar to true to allow the label to display an underlined accelerator key value. When ShowAccelChar is true, any character preceded by an ampersand (&) appears underlined. If the FocusControl property is set, the windowed control specified by the FocusControl property receives input focus when the user types that underlined character. To display an ampersand when ShowAccelChar is true, use two ampersands (&&) to stand for the single ampersand that is displayed. 

Set ShowAccelChar to false to display the label text with all ampersands appearing as ampersands. When ShowAccelChar is false, the value of the FocusControl property is not used.  

C++ Examples: 

 

/*
This example uses two labels on a form. The first label has
a caption with an accelerator character in it. The second
label also includes an ampersand, but it does not appear as
an accelerator character.
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Label1->ShowAccelChar = true;
  Label1->Caption = "An &Underlined character appears here";
  Label2->ShowAccelChar = false;
  Label2->Caption = "An ampersand (&) appears here";
}

 

Delphi Examples: 

{
This example uses two labels on a form. The first label has
a caption with an accelerator character in it. The second
label also includes an ampersand, but it does not appear as
an accelerator character.
} 
procedure TForm1.FormCreate(Sender: TObject);
begin
  Label1.ShowAccelChar := True;
  Label1.Caption := 'An &Underlined character appears here';
  Label2.ShowAccelChar := False;
  Label2.Caption := 'An ampersand (&) appears here';
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!