简体   繁体   English

C#Winforms ListView DoubleClick事件随处可见

[英]C# Winforms ListView DoubleClick event anywhere

I'm trying to get the following functionality in my winform: 我正在尝试在Winform中获得以下功能:

I need so that every time a someone double clicks inside my ListView, something will happen, but the event seems to only trigger when double clicking on a row containing an item in the ListView instead of anywhere in the ListView (including the empty area below all the items). 我需要每次有人在我的ListView中双击时都会发生某些事情,但是该事件似乎仅在双击包含ListView中某项的行而不是ListView中任何地方(包括所有下方的空白区域)时触发这几项)。

What event will fire when double clicking anywhere in the ListView? 双击ListView中的任意位置会触发什么事件?

Thanks 谢谢

您可以使用ListView1_MouseDown事件,而不是单击

You can probably achieve the required behavior by inheriting from ListView, and overriding the method OnNotifyMessage(). 您可以通过继承ListView并重写方法OnNotifyMessage()来实现所需的行为。

In that method, you'll have to intercept the correct message: WM_LBUTTONDBLCLK (or similar). 在这种方法中,您将必须截取正确的消息:WM_LBUTTONDBLCLK(或类似消息)。

That's not going to be the prettiest code you've ever written, but should get you the results. 那不会是您编写过的最漂亮的代码,但是应该可以为您带来结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM