Click to See Complete Forum and Search --> : Tabbing through controls
CodeBlue
October 29th, 2000, 10:50 PM
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
Bob Coleman
October 29th, 2000, 11:55 PM
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.
Bob Coleman
October 30th, 2000, 12:26 AM
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
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.