如何在tdbgrid.dblclick(发件人:tobject)上获取单击列?
当使用TDBGrid的OnDblClick事件时,我怎么知道哪列是双击的?
对于OnCellClick,它具有TCOLUMN参数,但在Ondblick上不容易。
When using the OnDblClick event of a TDBGrid, how can i know what column was double clicked ?
This is easy with the OnCellClick as it has a TColumn parameter, but not on OnDblClick.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 tdbgrid.ondblick tdbgrid 中,数据集位于单击记录中,可以使用 tdbgrid.selectedIndex 属性检索列。如果您对基础数据集字段感兴趣,则可以使用 tdbgrid.selectedfield 直接访问它。
During TDBGrid.OnDblClick the dataset is positioned to the clicked record and the column can be retrieved with the TDBGrid.SelectedIndex property. If you are interested in the underlying dataset field, you can directly access it with TDBGrid.SelectedField.
ondblick
事件不会为您提供有关单击的任何信息,特别是在执行单击的情况下,更不用说单击哪个网格单元格了。因此,您必须手动确定该信息。尝试以下尝试:
鼠标
传递给tdbgrid.screentoclient()
tdbgrid.mousecoord()
tdbgrid.screentoclient()代码>确定鼠标下方的单元格的行/列索引。tdbgrid.selectedIndex
属性将属性索引到tdbgrid.columns
属性。这基本上是与
tdbgrid
在触发oncellClick
事件时内部执行的事情,只有它对Mouseup
事件进行响应,该事件提供了小鼠在网格中坐标,从而跳过上方的第一步。例如:
update :基于 @uweraabe的评论,您应该能够单独使用
tdbgrid.selectedIndex
本身:The
OnDblClick
event doesn't give you any information about the click, in particular where the click was performed, let alone which grid cell was clicked on. So, you will have to determine that information manually.Try this:
Mouse.CursorPos
toTDBGrid.ScreenToClient()
TDBGrid.MouseCoord()
to determine the row/column indexes of the cell that is underneath the mouse.TDBGrid.SelectedIndex
property to index into theTDBGrid.Columns
property.This is basically the same thing that
TDBGrid
does internally when firing theOnCellClick
event, only it does this in response to aMouseUp
event, which provides the mouse coordinates within the grid, thus skipping the 1st step above.For example:
UPDATE: based on @UweRaabe's comments, you should be able to just use
TDBGrid.SelectedIndex
by itself: