2011-10-08 80 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