简体   繁体   中英

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 query 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM