listview OnToolTip event
Return to Introduction  Previous page  Next page
Applies to
acListView and acDBListView components.  

Declaration
type  
  TacListViewToolTipEvent = procedure(Sender: TObject; var ToolTipText: String; Item: TListItem; LogicalCol: Integer) of object;  
 
property OnToolTip: TacListViewToolTipEvent;  

Description
The OnToolTip event occurs when the acListView is about to show the tooltip (hint) for some partially hidden list item.  
 
Write OnToolTip event handler to specify custom text for the tooltips. Use ToolTipText parameter to get or set the tooltip text for specific list item. To determinate the list item under mouse pointer — use Item parameter. To determinate whether this item was a subitem — read the column number from the LogicalCol parameter.  

Screenshot (custom tooltips shows ID3 tags of MP3 files)
aclistviewss9  

Example
procedure TformSearch.SearchResultsListViewToolTip(Sender: TObject;  
  var ToolTipText: String; Item: TListItem; LogicalCol: Integer);  
begin  
  with SearchResultsListView do  
   if ToolTipText = '' then  
    begin  
     // Dynamically change the tooltip style  
     ToolTipOptions := [ttoLongStay, ttoOffset];  
     with Item do  
      ToolTipText := 'Name: ' + Item.Caption + #13#10 +  
                     'Sex: ' + SubItems[0] + #13#10 +  
                     'Age: ' + SubItems[1] + #13#10 +  
                     'Location: ' + SubItems[2];  
    end  
   else  
    // Dynamically change the tooltip style  
    ToolTipOptions := [];  
end;  

See also
ShowToolTip and ToolTipOptions properties.