Gopal
Gopal

Reputation: 11982

Form is not showing properly

using VB.Net

Code

 If e.Modifiers = Keys.Control 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

Upvotes: 1

Views: 190

Answers (1)

IAbstract
IAbstract

Reputation: 19881

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?

Upvotes: 1

Related Questions