我需要一个DBGrid OnAfterCellClick [英] I need a DBGrid OnAfterCellClick

查看:58
本文介绍了我需要一个DBGrid OnAfterCellClick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

当用户单击网格2时,我想使用定位"选择网格3中的行

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

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

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

似乎直到OnCellClick事件之后,网格才更改为行.

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

我需要一个AfterCellClick事件.

I need an AfterCellClick event.

有人可以阐明该如何做吗?

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

谢谢

推荐答案

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

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.

这篇关于我需要一个DBGrid OnAfterCellClick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆