Results 1 to 7 of 7

Thread: which way to "autotab" from textbox ?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    3

    which way to "autotab" from textbox ?

    my screen have some textbox, and I want to goto next textbox when I press ENTER (finish input) on one textbox (same textbox in VB6 Mircosoft Forms 2.0 object library)
    thanks any help!
    a beginner

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    VB Code:
    1. Private Sub TextBox1_KeyDown(ByVal sender As Object, _
    2.                                  ByVal e As System.Windows.Forms.KeyEventArgs) _
    3.                                  Handles TextBox1.KeyDown
    4.         If e.KeyCode = Keys.Enter Then
    5.             TextBox2.Focus()
    6.         End If
    7.     End Sub
    This world is not my home. I'm just passing through.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    3

    thank you, but ...

    if I have 100 textbox, so I must write 100 event like this!

  4. #4
    Member
    Join Date
    Jul 2003
    Location
    Sweden
    Posts
    62
    Don´t think you need 100 events like that.
    You got one event which feels if the enter button is pressed down.
    If enterbutton is pressed down. Just goto next textbox.

    quote:
    If e.KeyCode = Keys.Enter Then
    TextBox2.Focus()
    End If
    --------------------

    To something like...
    if e.KeyCode = Keys.Enter Then
    if TextBox1.Focus()=True Then
    TextBox2.Focus()
    elseif TextBox2.Focus()=True Then
    TextBox3.Focus()
    elseif...
    ...
    ...
    Endif

    Think you can do something like that
    //Martin Andersson

  5. #5
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    You only need one event... you also don't need to an IF else for 100 scenarios...

    Set the Form's keyPreview property to True..either in code or using the Properties window...
    and try this:

    VB Code:
    1. Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    2.         If e.KeyCode = Windows.Forms.Keys.Enter Then
    3.             Me.SelectNextControl(Me.ActiveControl, True, True, True, True)
    4.          'selectnextcontrol(control to move from, forward=true back=false,tabstopsonly = true or false, stop at nested controls=true, go back to beginning if at end=true)
    5.  
    6.         End If
    7.     End Sub
    Last edited by nemaroller; Aug 21st, 2003 at 07:25 PM.

  6. #6
    Lively Member
    Join Date
    Jul 2003
    Location
    Kuala Lumpur (Malaysia)
    Posts
    92

  7. #7
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I wouldn't rely on SendKeys...

    You have few choices, SendWait probably being your best bet if you were to implement that solution. In that way, you can be 99.9% sure the message will be processed properly.

    Best to rely on the parent container to handle the messaging.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width