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. Move cursor to next textbox

Move cursor to next textbox

Scheduled Pinned Locked Moved Visual Basic
8 Posts 4 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.
  • K Offline
    K Offline
    KARFER
    wrote on last edited by
    #1

    Hi all I have 3 textbox in the form and i make the Property MaxLength to 3 and i want that when i enter 3 letter in first textbox the cursor move auto to the next and so on

    -*-*-*-*-*-*-*-*-* To Be Or Not To Be (KARFER) -*-*-*-*-*-*-*-*-*

    C A 2 Replies Last reply
    0
    • K KARFER

      Hi all I have 3 textbox in the form and i make the Property MaxLength to 3 and i want that when i enter 3 letter in first textbox the cursor move auto to the next and so on

      -*-*-*-*-*-*-*-*-* To Be Or Not To Be (KARFER) -*-*-*-*-*-*-*-*-*

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      capture the keypress event, and when the third key is pressed call the Focus() method of the next textbox. To be clear, don't count keypresses, check the length of the string. And keyup may be a better one to use.

      Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • K KARFER

        Hi all I have 3 textbox in the form and i make the Property MaxLength to 3 and i want that when i enter 3 letter in first textbox the cursor move auto to the next and so on

        -*-*-*-*-*-*-*-*-* To Be Or Not To Be (KARFER) -*-*-*-*-*-*-*-*-*

        A Offline
        A Offline
        Ajay k_Singh
        wrote on last edited by
        #3

        Use KeyPress event of first text box to check length text and if it is three move focus to second text box. Such as – ------------------------------- Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If Me.TextBox1.Text.Length = 3 Then e.Handled = True Me.TextBox2.Focus() End If End Sub ------------------------------- -Ajay.

        ------------------------- www.componentone.com -------------------------

        C M 2 Replies Last reply
        0
        • A Ajay k_Singh

          Use KeyPress event of first text box to check length text and if it is three move focus to second text box. Such as – ------------------------------- Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If Me.TextBox1.Text.Length = 3 Then e.Handled = True Me.TextBox2.Focus() End If End Sub ------------------------------- -Ajay.

          ------------------------- www.componentone.com -------------------------

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Thanks for repeating my answer, only what you've posted, requires pushing a fourth key, which never appears in either textbox, in order to move focus.

          Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          1 Reply Last reply
          0
          • A Ajay k_Singh

            Use KeyPress event of first text box to check length text and if it is three move focus to second text box. Such as – ------------------------------- Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If Me.TextBox1.Text.Length = 3 Then e.Handled = True Me.TextBox2.Focus() End If End Sub ------------------------------- -Ajay.

            ------------------------- www.componentone.com -------------------------

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            If you replace Textbox1 with sender then you can handle both TextBox1 and TextBox2 with the same method

            Never underestimate the power of human stupidity RAH

            C 1 Reply Last reply
            0
            • M Mycroft Holmes

              If you replace Textbox1 with sender then you can handle both TextBox1 and TextBox2 with the same method

              Never underestimate the power of human stupidity RAH

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Except you would be better to write a class to handle this, so you can easily set what textbox2 is, for each textbox.

              Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              M 1 Reply Last reply
              0
              • C Christian Graus

                Except you would be better to write a class to handle this, so you can easily set what textbox2 is, for each textbox.

                Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                M Offline
                M Offline
                Mycroft Holmes
                wrote on last edited by
                #7

                Ok I'll bite - why. Having a single method to service the multiple textboxes seems the most efficient (assuming you do not want to reuse it outside this form) Ah, I had to read that 5 times to get it - set the destination/next textbox. I would have thought either hard code the target or use the form tab order to identify the next control. Oh sh;t now I remebered why I hate these things, I just envisaged a complete UI class to handle all the silly operations that can crop up shudder.

                Never underestimate the power of human stupidity RAH

                C 1 Reply Last reply
                0
                • M Mycroft Holmes

                  Ok I'll bite - why. Having a single method to service the multiple textboxes seems the most efficient (assuming you do not want to reuse it outside this form) Ah, I had to read that 5 times to get it - set the destination/next textbox. I would have thought either hard code the target or use the form tab order to identify the next control. Oh sh;t now I remebered why I hate these things, I just envisaged a complete UI class to handle all the silly operations that can crop up shudder.

                  Never underestimate the power of human stupidity RAH

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  Yeah, I guess it depends on if you expect to reuse it across several forms, etc. If you had three textboxes and that was it, you could just have a switch statement or use the tag on the textbox to identify the next one or something.

                  Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                  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