Hello,
I use DBGrid's onDrawColumnCell event to show row numbers there:
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (DataCol = 0) then
DBGrid1.Canvas.TextOut(Rect.Left + 2, Rect.Top, IntToStr(DBGrid1.DataSource.DataSet.RecNo));
end;
At a first glance it seems to work, but when I scroll down the DBGrid, and start to scroll it up by either mouse wheel or arrow up key of keyboard, it won't go up and starts repeating records strangely from lower sections.
You can find attached a very small zip packed demo project to be able to reproduce the issue. I was able to reproduce it using Lazarus 1.6.2 on both Windows 7 x86 and Ubuntu x64. Demo contains a simple SQLite database as source of data to display.
If I comment out the contents of onDrawColumnCell event, DBGrid will start behaving normally again, but I would loose the rowIDs.
- Is there any other way to show RowIDs in DBGrid?
- Or do you have ideas, how I can solve the strange issue of scrolling up?
Thank you in advance.