Search code examples
vb.netmdi

MDI menu shortcut not working while other Form active


My project have MDI form and it 's have a menu with many shortcut all shortcut work fine while it 's focus but when I open any form all shortcut stop working because the MDI form not active How I can send keyboard press to the mdi form to trigger the menu shortcut

this how i open child window

 FrmChild.Owner = Me
 FrmChild.Show()

I make the key press , key down events static and public and but them in the key press ,key down in the child form it 's work and I sent the keyboard input to the MDI form but menu shortcut never trigger.

frmMDI

Public Shared Sub frmMDI_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown

End Sub

frmChild

Private Sub FrmChild_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
    frmMDI.frmMDI_KeyDown(sender, e)
End Sub

thanks.


Solution

  • You don't need the call in the child keydown handler to the mdiparent keydown handler. The menu shortcut of the parent will work without this. The reason it's not working is because you should have

    FrmChild.MdiParent = Me
    

    instead of

    FrmChild.Owner = Me