Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Force a Tab

Force a Tab

Scheduled Pinned Locked Moved Visual Basic
helptutorial
9 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cory Kimble
    wrote on last edited by
    #1

    I have tried to search for an answer on line but maybe my search choices are worded wrong. I have a form that has multiple text boxes. (Just like many forms) I am using a barcode scanner to input data into the textboxes. I put a enter post amble in the scanner to go to the next field, and it works. The form gives the user the ability to lock fields and keep those values in the textboxes for multiple iterations of the form entry. I lock textfields by changing enabled to false. Issue: When I scan the text box previous to a locked textbox the cursor will not tab over the locked field. I do not want to put a tab in the scanner do to other issues on that page. I want to know if there is a way to force a tab through code. Example: When the textbox is validated then force tab to tab to next unlocked textbox. Thank you for any help you offer.

    W P A D 4 Replies Last reply
    0
    • C Cory Kimble

      I have tried to search for an answer on line but maybe my search choices are worded wrong. I have a form that has multiple text boxes. (Just like many forms) I am using a barcode scanner to input data into the textboxes. I put a enter post amble in the scanner to go to the next field, and it works. The form gives the user the ability to lock fields and keep those values in the textboxes for multiple iterations of the form entry. I lock textfields by changing enabled to false. Issue: When I scan the text box previous to a locked textbox the cursor will not tab over the locked field. I do not want to put a tab in the scanner do to other issues on that page. I want to know if there is a way to force a tab through code. Example: When the textbox is validated then force tab to tab to next unlocked textbox. Thank you for any help you offer.

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Check that your locked control has TabStop property set to false. That could be the reason if the focus goes to the locked control. Also since you now the layout of your form, one way could be that you programmatically use SetFocus method on the control where you want to go.

      The need to optimize rises from a bad design.My articles[^]

      C 1 Reply Last reply
      0
      • C Cory Kimble

        I have tried to search for an answer on line but maybe my search choices are worded wrong. I have a form that has multiple text boxes. (Just like many forms) I am using a barcode scanner to input data into the textboxes. I put a enter post amble in the scanner to go to the next field, and it works. The form gives the user the ability to lock fields and keep those values in the textboxes for multiple iterations of the form entry. I lock textfields by changing enabled to false. Issue: When I scan the text box previous to a locked textbox the cursor will not tab over the locked field. I do not want to put a tab in the scanner do to other issues on that page. I want to know if there is a way to force a tab through code. Example: When the textbox is validated then force tab to tab to next unlocked textbox. Thank you for any help you offer.

        P Offline
        P Offline
        programmervb netc
        wrote on last edited by
        #3

        It sounds like there is no set tab order, that you are figuring out at runtime. I use this to enable/disable our controls tabstops,

        ''' ''' This sets the tab stops to false when in inquire mode and tab stops to true if in update mode.
        ''' 
        ''' C is the control from the calling form
        ''' This sets the control tabstops to True (enabled) false (disabled)
        ''' 
        Public Sub sInitializeControls(ByVal c As Control, ByVal bStatus As Boolean)
            'This routine needs to be ran after a form is loaded 
            'When we enable and disable controls the cursor will stop on the controls that have been disabled
            'This is a recursive function
            'c = Control from Calling form
            '
            Dim ctrl As Control
            For Each ctrl In c.Controls
                If String.Compare(ctrl.Name, "btnClose") = 0 Or String.Compare(ctrl.Name, "btnCancel") = 0 Then
                    'exit
                Else
                    ctrl.TabStop = bStatus
                    If ctrl.HasChildren Then
                        sInitializeControls(ctrl, bStatus)
                    End If
                End If
            Next
        End Sub
        

        You might be able to modify this to your needs. I would think you could call this to set all tab stops false and then in the validation routine you could set the specific control you are wanting to move to like so control.tabstop = true control.focus() or control.select()I have found the latter of these two to be more reliable

        Humble Programmer

        C 1 Reply Last reply
        0
        • P programmervb netc

          It sounds like there is no set tab order, that you are figuring out at runtime. I use this to enable/disable our controls tabstops,

          ''' ''' This sets the tab stops to false when in inquire mode and tab stops to true if in update mode.
          ''' 
          ''' C is the control from the calling form
          ''' This sets the control tabstops to True (enabled) false (disabled)
          ''' 
          Public Sub sInitializeControls(ByVal c As Control, ByVal bStatus As Boolean)
              'This routine needs to be ran after a form is loaded 
              'When we enable and disable controls the cursor will stop on the controls that have been disabled
              'This is a recursive function
              'c = Control from Calling form
              '
              Dim ctrl As Control
              For Each ctrl In c.Controls
                  If String.Compare(ctrl.Name, "btnClose") = 0 Or String.Compare(ctrl.Name, "btnCancel") = 0 Then
                      'exit
                  Else
                      ctrl.TabStop = bStatus
                      If ctrl.HasChildren Then
                          sInitializeControls(ctrl, bStatus)
                      End If
                  End If
              Next
          End Sub
          

          You might be able to modify this to your needs. I would think you could call this to set all tab stops false and then in the validation routine you could set the specific control you are wanting to move to like so control.tabstop = true control.focus() or control.select()I have found the latter of these two to be more reliable

          Humble Programmer

          C Offline
          C Offline
          Cory Kimble
          wrote on last edited by
          #4

          I have tried changing the tab stop with no luck. So, are you saying there is no way to force a tab through code?

          N 1 Reply Last reply
          0
          • W Wendelius

            Check that your locked control has TabStop property set to false. That could be the reason if the focus goes to the locked control. Also since you now the layout of your form, one way could be that you programmatically use SetFocus method on the control where you want to go.

            The need to optimize rises from a bad design.My articles[^]

            C Offline
            C Offline
            Cory Kimble
            wrote on last edited by
            #5

            I have tried the tabstop idea. It still does not work. I Need to know if there is a way to force a tab in code. If I can I think it will work. I want to try that before I write a bunch of code to change focus.

            W 1 Reply Last reply
            0
            • C Cory Kimble

              I have tried changing the tab stop with no luck. So, are you saying there is no way to force a tab through code?

              N Offline
              N Offline
              nlarson11
              wrote on last edited by
              #6

              does the gotfocus/enter routine fire if you hit tab? if so, test if the control is disabled and then issue a

              My.Computer.Keyboard.SendKeys("{TAB}")

              'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous 'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous

              1 Reply Last reply
              0
              • C Cory Kimble

                I have tried the tabstop idea. It still does not work. I Need to know if there is a way to force a tab in code. If I can I think it will work. I want to try that before I write a bunch of code to change focus.

                W Offline
                W Offline
                Wendelius
                wrote on last edited by
                #7

                You can simulate tab with SendKeys, but I think it would be easier to call for example: Select Method[^]. When you say that it doesn't work, do you mean that the focus goes to the locked control even though it's TabStop is False or does tho focus go somewhere else?

                The need to optimize rises from a bad design.My articles[^]

                1 Reply Last reply
                0
                • C Cory Kimble

                  I have tried to search for an answer on line but maybe my search choices are worded wrong. I have a form that has multiple text boxes. (Just like many forms) I am using a barcode scanner to input data into the textboxes. I put a enter post amble in the scanner to go to the next field, and it works. The form gives the user the ability to lock fields and keep those values in the textboxes for multiple iterations of the form entry. I lock textfields by changing enabled to false. Issue: When I scan the text box previous to a locked textbox the cursor will not tab over the locked field. I do not want to put a tab in the scanner do to other issues on that page. I want to know if there is a way to force a tab through code. Example: When the textbox is validated then force tab to tab to next unlocked textbox. Thank you for any help you offer.

                  A Offline
                  A Offline
                  Alan N
                  wrote on last edited by
                  #8

                  Take a look at the Control.SelectNextControl method. It may be what you want. Alan.

                  1 Reply Last reply
                  0
                  • C Cory Kimble

                    I have tried to search for an answer on line but maybe my search choices are worded wrong. I have a form that has multiple text boxes. (Just like many forms) I am using a barcode scanner to input data into the textboxes. I put a enter post amble in the scanner to go to the next field, and it works. The form gives the user the ability to lock fields and keep those values in the textboxes for multiple iterations of the form entry. I lock textfields by changing enabled to false. Issue: When I scan the text box previous to a locked textbox the cursor will not tab over the locked field. I do not want to put a tab in the scanner do to other issues on that page. I want to know if there is a way to force a tab through code. Example: When the textbox is validated then force tab to tab to next unlocked textbox. Thank you for any help you offer.

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    This shouldn't even be an issue. How I did it in the past is enable the Form's KeyPreview, then handle it's KeyDown event. This handler should look for the preamble keysequence, eat the keys so they don't go to the controls, then start reading each key and appending to a string, until you see the postamble sequence, being sure to eat those keys. Then you've got the barcode, having never input the thing into a TextBox.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                         2006, 2007, 2008

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups