Recent

Author Topic: [SOLVED] Lazarus 2.2.4: TDBGrid and Hint property  (Read 513 times)

stephanie

  • New Member
  • *
  • Posts: 27
[SOLVED] Lazarus 2.2.4: TDBGrid and Hint property
« on: November 14, 2022, 11:46:54 pm »
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
« Last Edit: November 16, 2022, 01:40:33 pm by stephanie »

dje

  • Full Member
  • ***
  • Posts: 133
Re: Lazarus 2.2.4: TDBGrid and Hint property
« Reply #1 on: November 16, 2022, 06:43:54 am »
Try changing CellHintPriority to chpAll

stephanie

  • New Member
  • *
  • Posts: 27
Re: Lazarus 2.2.4: TDBGrid and Hint property
« Reply #2 on: November 16, 2022, 01:40:19 pm »
Thank you very much, it works!!

A curiosity, CellHintPriority is an only design time property?

If I do by code:

Code: Pascal  [Select][+][-]
  1. 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

  • Hero Member
  • *****
  • Posts: 10481
Re: Lazarus 2.2.4: TDBGrid and Hint property
« Reply #3 on: November 16, 2022, 02:10:53 pm »
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:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   with DBGrid1 do
  4.   begin  
  5.     ShowHint:= True;
  6.     CellHintPriority:= chpAllNoDefault;
  7.     Options:= Options
  8.               + [dgCellEllipsis]
  9.               + [dgTruncCellHints]
  10.               + [dgCellHints]
  11.               ;  
  12.   end;
  13. end;
  14.  
  15. procedure TForm1.DBGrid1GetCellHint(Sender: TObject; Column: TColumn;
  16.   var AText: String);
  17. begin
  18.   AText := 'This is the hint text for field "' + Column.Field + '"';
  19. end;
  20.  

See also: https://wiki.lazarus.freepascal.org/Grids_Reference_Page#Cell_hints


stephanie

  • New Member
  • *
  • Posts: 27
Re: [SOLVED] Lazarus 2.2.4: TDBGrid and Hint property
« Reply #4 on: November 16, 2022, 10:24:39 pm »
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


wp

  • Hero Member
  • *****
  • Posts: 10481
Re: [SOLVED] Lazarus 2.2.4: TDBGrid and Hint property
« Reply #5 on: November 16, 2022, 11:05:57 pm »
I doubt that setting CellHintPriority to chpAll resolves your issue because chlAll already is the default value.
This statement of mine was wrong: the default value of CellHintPriority is chpAllNoDefault.

I aggree that when you want to see the "default hint" (the one assigned to the Hint property of the grid) CellHintPriority must be switched to chpAll.

Some internal logic in hint creation has been changed in May 2019 (commit 30f5f0b09d) to better support the long hints (hints can consist of a "long hint" and a "short hint" chained by a '|' character; issue https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/35453), but I checked the test program of that bug report, and everything looks correct in Laz/main.

 

TinyPortal © 2005-2018