Forum > LCL

[SOLVED] Lazarus 2.2.4: TDBGrid and Hint property

(1/2) > >>

stephanie:
Hello,
I've upgraded from Lazarus 2.0.4 to Lazarus 2.2.4, under Linux/GTK environnement (Ubuntu 22.04).
All ok, but I've noted that with Lazarus 2.2.4 the Hint of the DbGrid aren't showed any more (at runtime).
The ShowInt property is of course setted to True.
With Lazarus 2.0.4 the Hint property works correctly.
Anyone has the same problem?
How could I resolve?
Thank your for any reply.
Best regards,
Stephanie

dje:
Try changing CellHintPriority to chpAll

stephanie:
Thank you very much, it works!!

A curiosity, CellHintPriority is an only design time property?

If I do by code:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---MyDbGrid.CellHintPriority := chpAll;
I become error: Identifier not found "chpAll"

DBGrids is in the uses clause.

In any case, at design time I can set the property and resolve.

Thank you very much again!

Best regards,

Stephanie

wp:

--- Quote from: stephanie on November 16, 2022, 01:40:19 pm ---A curiosity, CellHintPriority is an only design time property?

--- End quote ---
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:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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

stephanie:
Thank your very much for your reply and for the detailed explanation.

However setting the CellHintPriority = chpAll has solved the problem.

Now I've added Grids to the uses clause of a pas module, so I can use a procedure that already set some DbGrid properties, and all DbGrids show the Hint.

The default value of CellHintPriority is chpAllNoDefault that works with Lazarus 2.0.4 but not with Lazarus 2.2.4.

With chpAll the Hint are showed also with Lazarus 2.2.4.

Thank you again to everyone for your help!

Best regards,

Stephanie

Navigation

[0] Message Index

[#] Next page

Go to full version