Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tab Stop vs Return Stop

Status
Not open for further replies.

GaryWilsonCPA

Technical User
Jul 19, 2000
253
US
On most objects placed on a form, there is a property called tab stop. In my case I have textboxes I want to tab through, The tab stop property works fine, but I havent found anything that allows me to use return in the same way as tab stop.

Can you have tab stop and return stop at the same time?
 
What do you mean? Are you saying you want the focus to move to the next control when the user hits the enter key?
 
Yes. Some users prefer to tabbing through a screen of textboxes, some users prefer entering through a screen of textboxes.

I want the user to be able to do either. Just not sure what the method of coding is.

Thanks
 
There are a variety of ways to do it. There have been numerous topics concerning it in this forum. Although, it seems harder to do a search now. But back with VB 6, a suggestion I saw on Expert's Exchange was to enable then disable the textbox. This seems to port well to .Net. It would go something like this:

Code:
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress, TextBox2.KeyPress
        Dim t As TextBox = CType(sender, TextBox)
        Select Case e.KeyChar
            Case ControlChars.CrLf
                e.Handled = True
                t.Enabled = False
                t.Enabled = True
        End Select
    End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top