Created On:  31 May 2012

Problem:

I have many TextBox controls on my Windows Form and I would like the focus to automatically jump to the next control when the TextBox control is filled with text.  How do I do this?

Resolution:

There is an example attached to this article that demonstrates one method of accomplishing an autotab functionaility for TextBox controls on a Windows Form.

Example Description:

                    TESTAUTOTAB

This example program demonstrates one method of implementing an autotab function to move between controls when a TextBox field is filled to iots maximum length. There are 4 TextBox controls on the form and each has its maxlength property set to 3. Everytime a character is entered into one of the TextBox controls a TextChange event is triggered. Each of the TextBox controls has the method check_TextChanged set as its event handler. The eventhandler checks the current length of the TextBox control against its maximum size and if they are equal it generates a Tab key press using the SendKeys::Key method.

class-id testautotab.Form1 is partial
   inherits type System.Windows.Forms.Form.

working-storage section.
method-id NEW.
procedure division.
   invoke self::InitializeComponent
goback.
end method.

method-id button1_Click final private.
procedure division using by value sender as object e as type System.EventArgs.
   invoke self::Close
end method.

method-id check_TextChanged final private.
procedure division using by value sender as object e as type System.EventArgs.
   if sender as type TextBox::MaxLength = sender as type TextBox::Text::Length
      invoke type SendKeys::Send("{TAB}")
   end-if
end method.
end class.