Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

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

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

probably
 
Share this answer
 
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:

C#
<mousedoubleclickhandlermethodname>(<listviewname>, <yourargsobject>);</yourargsobject></listviewname></mousedoubleclickhandlermethodname>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900