Delphi DBGrid scrolling with mouse
I have a dbgrid and on its datasources onchange event there is some code that does some work and it takes 2-3 seconds. when i scroll with mouse weel on dbgrid thant code on datasource works for all rows that i have scrolled but i want it to work for the last row how can i do that. there is a afterscroll event for quer开发者_StackOverflow社区y but it also does the same
thanks
If I understand correctly...
What you need to do is, instead of executing the "OnChange" code in the Datasource event, you should start a timer(See TTimer) there, and execute the "OnChange" code in the OnTimer event.
In the OnChange, you should only start/reset the timer.
That way, if the user scroll many records, it will only execute your OnChange if the user stays idle too long on any record, most likely only once on the last record he scrolls to.
How long should be the timer is dependent on your own specific needs.
That will also work if the user scroll with the keyboard's arrow.
精彩评论