RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TControl.Hint Property

Contains the text string that can appear when the user moves the mouse over the control.

Pascal
property Hint: string;
C++
__property AnsiString Hint;

Use the Hint property to provide a string of help text either as a Help Hint, or as help text on a particular location such as a status bar. 

A Help Hint is a box containing help text that appears for a control when the user moves the mouse pointer over the control and pauses momentarily. To set up Help Hints: 

Specify the Hint property of each control for which a Help Hint should appear. 

Set the ShowHint property of each appropriate control to true, or set the ParentShowHint property of all controls to true and set the ShowHint property of the form to true. 

At runtime, set the value of the application's ShowHint property to true. 

To show the Hint on a status bar or other location, use the OnHint event handler of the application. The application's OnHint event occurs when the mouse pointer moves over the control. 

Specify a hint to be used for both a Help Hint box and by an OnHint handler by specifying two values separated by a | character (the vertical bar "or" symbol). For example,

Edit1.Hint := 'Name|Enter Name in the edit box';

 

Edit1->Hint = "Name|Enter Name in the edit box";

The "Name" part appears in the Help Hint box and the "Enter full name in the edit box" part can be extracted using the GetLongHint function for use in an OnHint event handler.  

If Hint contains only one value, the entire string is used as a Help Hint and returned by the GetLongHint function. If a control has no Hint value specified, but its parent control does, the control uses the Hint value of the parent control (as long as the control's ShowHint property is true).

Note: If the application's ShowHint property is false, the Help Hint does not appear, but the OnHint event handler is still called.
 

C++ Examples: 

 

/*
This example uses an edit box and a list box on a form.  
Items are added to the list box and a Help Hint is assigned 
to both controls. The last statement enables the Help Hints
for the entire application.
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Edit1->Hint = "Enter your name";
  Edit1->ShowHint = true;

  char string[10];
  char index[3];
  for(int i = 1; i <= 10; i++)
  {
    strcpy(string, "Item");
    itoa(i, index, 10);
    strcat(string, index);
    ListBox1->Items->Add(string);
  }
  ListBox1->Hint = "Select an item";
  ListBox1->ShowHint = true;
  Application->ShowHint = true;
}
/*
Note: To see an example that displays the hints of controls
in some place other than in a Help Hint box, see the OnHint
example.
*/

 

Delphi Examples: 

{
This example uses an edit box and a list box on a form.  
Items are added to the list box and a Help Hint is assigned 
to both controls. The last statement enables the Help Hints
for the entire application.
} 
procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
begin
  Edit1.Hint := 'Enter your name';
  Edit1.ShowHint := True;
  with ListBox1 do
  begin
    for I := 1 to 10 do
      Items.Add('Item ' + IntToStr(I));
    Hint := 'Select an item';
    ShowHint := True;
  end;
  Application.ShowHint := True;
end;
{
Note: To see an example that displays the hints of controls
in some place other than in a Help Hint box, see the OnHint
example.
}

 

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