Wednesday, July 02, 2008 4:37 PM
A friend of mine was developing a form for data entry and this form had several pages put as TabPages in a TabControl. The normal behavior of the Tab Order in TabPages is it loops the controls of the full form and the currently selected TabPage. The problem was that his client got used to going from one control to another control using the Tab key. It was frustrating for the client not to be able to smoothly continue from one TabPage to another just by using the Tab key.
So I helped my friend by developing a class called TabPageCircularTabOrder. Instead of adding TabPage instance to your TabControl, you create an instance of TabPageCircularTabOrder and it will take care of the rest. With this class, when you enter the controls inside a TabPage it will not leave the TabControl when you pass the last control on that page, instead it will open the next TabPage and start with the first control in that page and so on (circular Tab Order within the TabPages). When all the pages are done, the Tab Order continues with the normal Tab Order of the Form. Shift + Tab also is modified to circle the Tab Order in backwards.
What turned out to be a simple task at first took quite some time, but the final code is simple and small to understand.
Download the sample code here
Hope this helps. Let me know if you have any comments.