How to add keyboard event to a menuitem?

M

Michael

Hi,
There is a menuitem in my windows application called Fill Data.
If user click this menu, one of the textbox will be filled in some
value.
Now I hope it work like this,
When user clicks this menu, at the same time, he presses Ctrl key, all
the textboxes will be filled in with some values.
How can I do that? Seems there is no keypress event for a menuitem?
Thanks!
 
J

Jan Hyde (VB MVP)

"Michael" <[email protected]>'s wild thoughts were
released on 13 Apr 2007 19:27:53 -0700 bearing the following
fruit:
Hi,
There is a menuitem in my windows application called Fill Data.
If user click this menu, one of the textbox will be filled in some
value.
Now I hope it work like this,
When user clicks this menu, at the same time, he presses Ctrl key, all
the textboxes will be filled in with some values.
How can I do that? Seems there is no keypress event for a menuitem?
Thanks!

No but you can test the keyboard state when the item is
clicked. Something like this for example

If Control.ModifierKeys = Keys.Control Then
Me.Text = "CONTROL+CLICK"
Else
Me.Text = "CLICK"
End If
 
M

Michael

"Michael" <[email protected]>'s wild thoughts were
released on 13 Apr 2007 19:27:53 -0700 bearing the following
fruit:


No but you can test the keyboard state when the item is
clicked. Something like this for example

If Control.ModifierKeys = Keys.Control Then
Me.Text = "CONTROL+CLICK"
Else
Me.Text = "CLICK"
End If

Cool!!
It works!
Thank you very much!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top