每次TDbGrid的选定位置发生变化时会发生什么事件? [英] What event fires every time a TDbGrid's selected location is changed?

查看:128
本文介绍了每次TDbGrid的选定位置发生变化时会发生什么事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中有一个TDbGrid,每次更改所选行时,我都试图让事件发生。行中的任何更改已经更新了链接到同一DataSource的所有数据感知控件,但还有其他更改,我需要一个事件处理程序。

I've got a TDbGrid in my project, and I'm trying to have an event go off every time I change the selected row. Any change in row already updates all the data-aware controls linked to the same DataSource, but there are other changes to be made too, that I need an event handler for.

我以为OnColEnter会工作。根据帮助文件,它会在以下情况下触发:

I thought OnColEnter would work. According to the helpfile, it fires when:


  • 用户使用
    键盘导航到单元格。例如,当
    用户使用Tab键或Home
    键时。

  • The user navigates to the cell using the keyboard. For example, when the user uses the Tab key, or the Home key.

用户在单元格中单击
的鼠标按钮。

The user clicks the mouse button down in the cell.

已设置SelectedField或SelectedIndex
属性。

The SelectedField or SelectedIndex property is set.

不幸的是,当启用dgRowSelect选项时用户使用键盘导航,并且没有OnRowEnter,它不会触发。 OnKeyDown事件在选择更改之前触发。我试图在这里模拟一个TListBox的数据感知版本,我需要一些东西来替换ListBox的OnClick处理程序,尽管名称实际上随着选择的改变而关闭,无论是通过鼠标还是键盘。有没有办法用TDbGrid这样做?如果没有,那么必须要有一些其他的网格控制。有人知道是什么吗? (优选开源?)

Unfortunately, it does not fire when the user navigates using the keyboard while the dgRowSelect option is enabled, and there's no OnRowEnter. And the OnKeyDown event fires before the selection change has been made. I'm trying to simulate a data-aware version of a TListBox here, and I need something to replace the List Box's OnClick handler, which despite the name actually goes off anytime the selection is changed, whether through the mouse or the keyboard. Is there any way I can do that with a TDbGrid? If not, there's got to be some other grid control that will do it. Does anyone know what it is? (Preferably open source?)

推荐答案

OnDataChange是一个选择。另一个是在TDataset方面的事件AfterScroll。大多数时候,我发现它比OnDataChange更实用;因为在OnDataChange中,一个滚动事件带有Field参数nil(这是一个陷阱,可能是您的AV编码的原因之一)。

OnDataChange is one choice. The other is, on TDataset side, the event AfterScroll. Most times, I found it more practical than OnDataChange; because in OnDataChange a scroll event comes with the Field parameter nil (which is a trap and can be one of the cause of your AVs coding it).

这篇关于每次TDbGrid的选定位置发生变化时会发生什么事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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