I need a DBGrid OnAfterCellClick

痴心易碎 提交于 2019-12-12 01:15:53

问题


I have three DBGrids and three Tables, and two of them are linked with Master Fields and work as expected. When the user clicks on grid-1, it shows three items in grid-2.

When the user clicks on grid-2, I want to use Locate to select the Row in grid-3

Problem is that the grid-2 OnCellClick event is fired before the data has changed to the appropriate Row. e.g.

Grid-2
Flowers  <-- this has focus and Dirt has focus in grid-3
Weeds    
Trees    <-- then I click here

Grid-3
Dirt
Water
Gum     <-- and using Locate in the grid-2 OnCellClick I
            want it to show Gum but grid two is still 
            internally on Flowers and stays on Dirt

It seems that the grid does not change to the Row until after the OnCellClick event.

I need an AfterCellClick event.

Can someone please shed some light on how to go about that?

Thanks


回答1:


You shouldn't be using OnCellClick. Use the TDataSet.OnAfterScroll instead. It's called automatically when the record (row) pointer is moved, after the movement is done. This means that when the grid attached to the second table is clicked and the record pointer is moved from Flowers to Trees, the second table's OnAfterScroll event will be fired after the row changes, and in that event handler you can do the appropriate Locate in the third table.



来源:https://stackoverflow.com/questions/15736437/i-need-a-dbgrid-onaftercellclick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!