鼠标双击事件输入按键 [英] mouse double click event on enter key press

查看:93
本文介绍了鼠标双击事件输入按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi


我有一个鼠标双击事件的事件处理程序,现在我想要的是在keydown事件上调用相同的处理程序但是有任何办法这样做..



请帮助



这里是我正在使用的代码。



hi
I am having an event handler for mouse double click event , now what i want is to call the same handler on keydown event but getting any way to do so..

please help

here is the code that I am using.

if (e.KeyCode == Keys.Enter)
            {
                MyDelegate m = new MyDelegate(listView1.MouseDoubleClick);
                this.Invoke(listView1.MouseDoubleClick);
            }

推荐答案

你可以这么做

listView1.MouseDoubleClick(null,null);



可能
you could just do
listView1.MouseDoubleClick(null,null);

probably


您正在使用ListView并且您已经处理了鼠标单击[DoubleClick]事件。我猜你正在使用MouseEventArgs对象somwhere。如果不是,您可以创建一个包含所有代码的方法,然后您可以在click-handler和key-handler中调用该方法。如果您正在使用MouseEventArgs对象,那么,在键事件处理程序中,您可能需要创建一个MouseEventArgs类对象< yourargsobject>并相应地设置属性(如果args对象允许你这样做)然后你将需要应用_Maxxx_建议的解决方案,稍作修改:



You are using ListView and you have already handled Mouse Click[DoubleClick] event. I guess you are using the MouseEventArgs object somwhere. If you are not, you can create a method which contains all your code and then you can call the method in your click-handler as well as key-handler. If you ARE using the MouseEventArgs object, then, in key event handler, you probably need to create a MouseEventArgs class object <yourargsobject> and set the properties accordingly (if args object allows you to do so) and then you will be needed to apply solution suggested by _Maxxx_ with slight modification as:

<mousedoubleclickhandlermethodname>(<listviewname>, <yourargsobject>);</yourargsobject></listviewname></mousedoubleclickhandlermethodname>


这篇关于鼠标双击事件输入按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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