Lazarus

Programming => Databases => Topic started by: Elmug on July 21, 2012, 03:06:49 pm

Title: [SOLVED] Need to trigger code when moving down or up in same column...
Post by: Elmug on July 21, 2012, 03:06:49 pm
Hi everyone,

I would appreciate help in how to trigger Code (procedure) whenever while staying in same column of a DBGrid, one moves up or down, be it by mouse click, by arrow-keys, or by navigator.

If we'd have an event "OnCellEnter", that would do it. But, unfortunately, we do not (that I can find). I hope there's a way that I have missed.

We do have "OnEnter", but I believe that's for entering the DBGRid.

Thanks for any advice.
Title: Re: Need to trigger code when moving down or up in same column...
Post by: taazz on July 21, 2012, 05:05:56 pm
SQLQuery.AfterScroll & BeforeScroll are the only events that I know off that are raised when you scroll up or down a dbgrid.
Title: Re: Need to trigger code when moving down or up in same column...
Post by: Elmug on July 21, 2012, 05:10:47 pm
Thank you taazz,

I did not try those but will, and report back.

I actually had thought that by scroll they meant moving the scroll bar up or down, which only moves the image view. :(
Title: Re: Need to trigger code when moving down or up in same column...
Post by: Elmug on July 22, 2012, 11:59:39 am
SQLQuery.AfterScroll & BeforeScroll are the only events that I know off that are raised when you scroll up or down a dbgrid.

Thank you taaz,

The SQLQuery1 AfterScroll event does indeed work as asked.

I did have to also repeat the same Code (procedure) to the DBGrid OnCelClick, otherwise, I don't quite get the equivalent action of a needed OnCellEnter new event that I solicit be ADDED to Lazarus capabilities, and also an OnCellExit event.

It is not exactly what I wanted, but is close enough. The best would be with the not available event OnCellChange.

Also, the AfterScroll surely depends on the SQLQuery being active, and I have not yet tested to see if that matters or not. And, there may be cases with timing issues, as to when the AfterScroll event takes place and when DBGrid events act, if one is using also DBGrid Events to trigger additional required code.

BUT, please, Lazarus Team: Would you please consider adding these events (obvious needs for the request) to the DBGrid:

1. OnCellEnter
2. OnCellExit


Actually, I am surprised that these events are not available to the DBGrid, as usually it'd be one of the most useful events when jumping to a new cell, or after leaving it (where speciall checks and calculations can be required).

Thanks everyone!

P.S. Maybe the same request would apply to the other grids available?