Hello all.
I have the need of showing a hint with the content of a cell of a DBGrid when the mouse moves over the cell (not current cell).
I was using Lazarus 1.0.10 and FPC 2.6.2, and solved the issue with this code, simulating the hint with a memo control:
type
TMyGrid = Class(TCustomDBGrid);
procedure TForm1.dbgrid1MouseMove(Sender: TObject;Shift: TShiftState; X, Y: Integer);
var
row, col: integer;
rec: integer;
begin
inherited;
TDBGrid(Sender).MouseToCell(X, Y, col, row);
if dgTitles in TDBGrid(Sender).Options then
Dec(row);
if TMyGrid(TDBGrid(Sender)).DataLink.Active and (row >= 0) and (col = 2) then
begin
rec := TMyGrid(TDBGrid(Sender)).DataLink.ActiveRecord;
try
TMyGrid(TDBGrid(Sender)).DataLink.ActiveRecord := row;
Memo1.Text := TDBGrid(Sender).Columns[col].Field.AsString;
Memo1.Visible := True;
finally
TMyGrid(TDBGrid(Sender)).DataLink.ActiveRecord := rec;
end;
end
else
begin
Memo1.Text := '';
Memo1.Visible := False;
end;
end;
Last week I updated Lazarus to 1.6.4, FPC 3.02, and in the same code I have a typecast error at compliling:
Error: Class or Object types "TDBGrid" and "TMyGrid" are not relatedin every line with the code
TMyGrid(TDBGrid(Sender)).DataLink.ActiveIf I replace
TMyGrid(TDBGrid(Sender)).DataLink.Activewith
TMyGrid(TCustomDBGrid(Sender)).DataLink.Activei have no error at compliling, but this error at runtime:
Invalid TypeCastIf not use TMyGrid, using just the typecast
TCustomDBGrid(Sender).DataLink.Activei have this compliling error:
Error: identifier idents no member "DataLink"After a few days working on it, I still can't figure out how to solve this.
Any suggestion ?
I use Firebird and ZeosLib.
TKS !