开发者

Shortcut Key is not properly working in the form

Using VB.Net (Windows Application)

In the Form, textbox, combobox etc....

  ->  When i open the windows form, if i press ctrl + Enter, then pop windows is opening 
  ->  if i enter any data's in the text box, then i press ctrl + Enter, then pop windows is not opening

Code

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Me.KeyPreview = True
End Sub

Private Sub form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

        If e.KeyCode = Keys.Control + e.KeyCode = Keys.Enter Then
            frmList.sFormID = 51
            frmList.Show()
        End If

End Sub
开发者_运维知识库

When the form load, ctrl + Enter shortcut key is working, once i enter or select any data's in the form, then ctrl + Enter shortcut key is not working (not showing the popup windows)

What wrong in my code. How to solve this problem...

Need Vb.net code help


Set Form.KeyPreview=True and use Modifiers flag.

Private Sub form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
  If e.Modifiers = Keys.Control And e.KeyCode = Keys.Enter Then
     frmList.sFormID = 51
     frmList.Show()
  End If
End Sub
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜