CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2000
    Posts
    145

    Tabbing through controls

    I have a form with many TextBox controls. When tabbing through these controls and it gets to the last control, the next tab "wraps" around to the first control. Also shift-tab on the first control wraps to the last control. I want it to stop on the last control when tabbing, and stop on the first control when shift-tabbing. How can I make this work?

    Thanks for any suggestions!
    Brent Dirks


  2. #2
    Join Date
    Oct 2000
    Posts
    26

    Re: Tabbing through controls

    One way is to set all controls Tabstops properties to false(so that you can trap the tab key) and implement your own tab functionality, building in your first and last control requirements.


  3. #3
    Join Date
    Oct 2000
    Posts
    26

    Re: Tabbing through controls

    Or simply disable the tabstops for all controls on the gotfocus of both the first and last controls, and manually control the tab and shift tab events on those two controls, and finally on the lostfocus turn on all the tabstops again.


    Dim arrTabStop() as Boolean

    private Sub TextBox1_GotFocus()
    'Store the TabStop property for each control on the
    'form and then set the TabStop property of each
    'control to false

    ReDim arrTabStop(0 to Controls.Count - 1) as Boolean
    for i = 0 to Controls.Count - 1
    arrTabStop(i) = Controls(i).TabStop
    Controls(i).TabStop = false
    next
    End Sub

    private Sub TextBox1_LostFocus()
    'Restore the Tabstop property for each control on the form

    for i = 0 to Controls.Count - 1
    Controls(i).TabStop = arrTabStop(i)
    next
    End Sub






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

Featured