我需要一个DBGrid OnAfterCellClick

use*_*495 0 delphi delphi-5 tdbgrid

我有三个DBGrids和三个表,其中两个与Master Fields链接并按预期工作.当用户单击grid-1时,它会在grid-2中显示三个项目.

当用户点击grid-2时,我想使用Locate选择grid-3中的Row

问题是在数据更改为适当的行之前触发了grid-2 OnCellClick事件.例如

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
Run Code Online (Sandbox Code Playgroud)

似乎在OnCellClick事件之后,网格不会更改为Row.

我需要一个AfterCellClick事件.

有人可以说明如何去解决这个问题吗?

谢谢

Ken*_*ite 5

你不应该使用OnCellClick.使用TDataSet.OnAfterScroll来代替.在移动完成后移动记录(行)指针时会自动调用它.这意味着当单击附加到第二个表的网格并且记录指针从中移动Flowers到时Trees,第二个表的OnAfterScroll事件将在行更改后触发,并且在该事件处理程序中,您可以Locate在第三个表中执行相应的操作.