为TListView实现项目单击/双击

本文介绍了如何在Delphi的TListView控件中实现项目单击和双击事件。当用户在控件内点击时,TListView的OnClick和OnDblClick事件会被触发,但要获取被点击的项目,需要使用GetHitTestInfoAt函数来确定点击位置是否在项目上。文章提供了OnDblClick事件的示例实现,并强调了检查返回的THitTests类型来确保用户点击了项目或其相关元素。
摘要由CSDN通过智能技术生成

Delphi's TListView control displays a list of items in columns with column headers and sub-items, or vertically or horizontally, with small or large icons.

Delphi的 TListView控件在具有列标题和子项目的列中显示项目列表,或者在垂直或水平方向上显示带有小图标或大图标的项目列表。

As do most Delphi controls, the TListView exposes the OnClick and OnDblClick (OnDoubleClick) events.

与大多数Delphi控件一样,TListView公开OnClickOnDblClick (OnDoubleClick)事件。

Unfortunately, if you need to know what item was clicked or double clicked you cannot simply handle the OnClick / OnDblClick events to get the clicked item.

不幸的是,如果您需要知道单击或双击了哪个项目,则不能简单地处理OnClick / OnDblClick事件来获取被单击的项目。

The OnClick (OnDblClick) event for the TListView is fired whenever the user clicks the control - that is whenever the "click" occurs somewhere inside the client area of the control.

每当用户单击控件时,即在控件的客户区域内某处发生“单击”时,都会触发TListView的OnClick(OnDblClick)事件。

The user can click inside the list view, BUT "miss" any of the items. What's more, since list view can change its display depending on the ViewStyle property, the user might have clicked on an item,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值