Main Menu

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a main menu on a vb form. I have on the menu Exit Crtl+X. How do I
code this so I can close it on ctrl+x.
 
Hi Newbi,

When you assign a shortcut to an menuitem (Shorcut property) the menu item's
Click is raised whenever you use that shortcut. You don't have to do
enything more then to implement your item's Click event handler
 
Newbi said:
I have a main menu on a vb form. I have on the menu Exit
Crtl+X. How do I code this so I can close it on ctrl+x.

Add this to your menu item's 'Click' event handler:

\\\
Me.Close()
///
 
That is what I got for the click event. But how do I write the short cut key?
This is what I have been working with

Private Sub mainmenu_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.Control.X Then
MsgBox("So, you want to exit???")
Close()
End If

End Sub
 
Newbi said:
That is what I got for the click event. But how do I write the
short cut key?

Assign 'CtrlX' to the menu item's 'Shortcut' property at design time. No
additional code is required to make the shortcut fire the menu item's
'Click' event at runtime.
 
Back
Top