2011-10-08 79 views
0

使用VB.Net(Windows應用程序)快捷鍵不能正常形式

在形式上,文本框,組合框等工作....

-> 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 

代碼

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 

當窗體加載時,ctrl + Enter快捷鍵工作,一旦我輸入或選擇任何數據的形式,然後Ctrl + Enter快捷鍵不起作用(不顯示彈出窗口)

我的代碼有什麼問題。如何解決這個問題?

需要Vb.net代碼幫助

回答

1

設置Form.KeyPreview=True,並使用Modifiers標誌。

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