I'm having a problem with PageChange event when using mouse. If I change pages in footer, pagechange event fires normally, but if I'm moving through pages with a mouse wheel the event doesn't fire. What is a correct way to catch page change when using mouse wheel? I tried with latest version 2.0.0.2.
Thank you for the report. You are right: in the current version OnPageChanged is only triggered by the page buttons and the page selector in the footer. With paging, the page on display follows the scroll position, so scrolling to another page with the mouse wheel (and also with Page Down / Page Up, the arrow keys, the scroll bar or by selecting a cell on another page) changed the page without the event.
We have fixed this for the next update (TMS FNC UI Pack 7.3.1.10, TTMSFNCDataGrid 2.0.0.3). OnPageChanged is then triggered for every page change while Paging is enabled, with the old and the new page index. The page buttons in the footer work as before. Changing the page in code (PageIndex, GoToPage, FirstPage, LastPage, NextPage, PreviousPage) still does not trigger the event, as documented.
Until the update is available, you can catch the change in OnVScroll, which is triggered for every vertical scroll. The grid updates its visible rows right after this event, so check the page one message later:
// FLastPage: Integer, initialized with TMSFNCDataGrid1.PageIndex after loading the data
procedure TForm1.TMSFNCDataGrid1VScroll(Sender: TObject; APosition: Single);
begin
TThread.ForceQueue(nil,
procedure
begin
if TMSFNCDataGrid1.PageIndex <> FLastPage then
begin
PageChanged(FLastPage, TMSFNCDataGrid1.PageIndex); // your own handling
FLastPage := TMSFNCDataGrid1.PageIndex;
end;
end);
end;
Once you have updated, you can remove this code and use OnPageChanged directly