使用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代码帮助
答案 0 :(得分: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