A curiosity, CellHintPriority is an only design time property?
It is declared in unit Grids.
I doubt that setting CellHintPriority to chpAll resolves your issue because chlAll already is the default value. Because there are several kinds of cell hints enabling the grid hints is a bit more complex than just setting ShowHint to true.
/1/ There is the string passed to the usual Hint property of the component.
/2/ Each cell can have its own hint text. This is defined by the OnGetCellHint event handler. dgCellHints must be added to the Options of the DBGrid.
/3/ There is a hint for cells in which the text is wider than the cell and thus has been truncated, as indicated by the end ellipsis. dgTruncCellHints must be added to the DBGrid.Options (as well as dgCellEllipsis to see the end ellipsis).
CellHintPriority determines which kind of hint is to be displayed:
- chpAll --> all three hint texts (kinds /1/, /2/ and /3/)
- chpAllNoDefault --> only kinds /2/ and /3/.
- chpTruncOnly --> truncated hints only (kind /3/).
Here is an example of successful parameter combinations:
procedure TForm1.FormCreate(Sender: TObject);
begin
with DBGrid1 do
begin
ShowHint:= True;
CellHintPriority:= chpAllNoDefault;
Options:= Options
+ [dgCellEllipsis]
+ [dgTruncCellHints]
+ [dgCellHints]
;
end;
end;
procedure TForm1.DBGrid1GetCellHint(Sender: TObject; Column: TColumn;
var AText: String);
begin
AText := 'This is the hint text for field "' + Column.Field + '"';
end;
See also:
https://wiki.lazarus.freepascal.org/Grids_Reference_Page#Cell_hints