Recent

Author Topic: [SOLVED] Need to trigger code when moving down or up in same column...  (Read 2829 times)

Elmug

  • Hero Member
  • *****
  • Posts: 849
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.
« Last Edit: July 22, 2012, 12:00:53 pm by Elmug »

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: Need to trigger code when moving down or up in same column...
« Reply #1 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.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Need to trigger code when moving down or up in same column...
« Reply #2 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. :(

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Need to trigger code when moving down or up in same column...
« Reply #3 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?
« Last Edit: July 22, 2012, 12:48:47 pm by Elmug »