using VB.Net
Code
If e.Modifiers = Keys.Contr开发者_运维百科ol And e.KeyCode = Keys.Enter Then
If textbox1.Focus() = True Then
frmList.sFormID = 54
frmList.Show()
ElseIf textbox2.Focus() = True Then
frmList.sFormID = 55
frmList.Show()
End If
End If
When textbox1.focus() at that time i clicked Control + Enter key, the formid=55 is showing instead of formid=54.
What wrong with my code.
Need code help
Try the following:
If e.Modifiers = Keys.Control And e.KeyCode = Keys.Enter Then
If textbox1.Focused = True Then
frmList.sFormID = 54
frmList.Show()
ElseIf textbox2.Focused = True Then
frmList.sFormID = 55
frmList.Show()
End If
End If
Note that I changed the test condition to check for control focus. Your test condition is attempting to set focus to a text box but in failure, you are probably seeing a default value - e.g., the formid 55. Without seeing more of what frmList is, I'm really only guessing. Is this in an event method? If so, can you provide that code?
精彩评论