开发者

Form is not showing properly

开发者 https://www.devze.com 2023-04-11 20:38 出处:网络
using VB.Net Code If e.Modifiers = Keys.Contr开发者_运维百科ol And e.KeyCode = Keys.Enter Then If textbox1.Focus() = True Then

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?

0

精彩评论

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