EhLib.Com
https://forum.ehlib.com/en/

How to show hint by Cells ?
https://forum.ehlib.com/en/viewtopic.php?f=5&t=1129
Page 1 of 1

Author:  Luciano_F [ 30 Jan 2022, 13:36 ]
Post subject:  How to show hint by Cells ?

See this example attached works with DbGrid but does not work with DBGridEh
I enabled ShowHint on Grid and ToopTips on columns

Code:
Function TForm1.ChangeHint(C: TControl; Const Hint: String; p: TPoint): Boolean;
begin
if Hint <> OldHint then begin
  OldHint := C.Hint;

  C.Hint := Hint;

  Application.ActivateHint(p);
end;

procedure TForm1.DBGridEh1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
Var Dados : string;
begin
Dados := DBGridEh1.DataSource.Dataset.FieldByname('CODIGO').Asstring + '   ';
Dados := Dados + DBGridEh1.DataSource.Dataset.FieldByname('MERCADORIA').Asstring + #13;

ChangeHint(TDBGridEh(Sender),  Dados +  '  -  TDBGridEh', TDBGridEh(Sender).ClientToScreen(Point(X, Y)));

end;

end;



Attachments:
Hint Columns DBGrid.7z [16.11 KiB]
Downloaded 84 times

Author:  EhLibSupport [ 31 Jan 2022, 19:19 ]
Post subject:  Re: How to show hint by Cells ?

Hello

In the DBGridEh, each cell has its own algorithm for displaying hints.
To display the same hint for each grid cell, add the OnDataHintShow event handler like this:

Code:
procedure TForm1.DBGridEh1DataHintShow(Sender: TCustomDBGridEh;
  CursorPos: TPoint; Cell: TGridCoord; InCellCursorPos: TPoint;
  Column: TColumnEh; var Params: TDBGridEhDataHintParams;
  var Processed: Boolean);
begin
  Params.HintStr := Sender.Hint;
  Processed := True;
end;

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/