Textbox to textbox

Discussion in 'Questions (Windows Mobile)' started by kavka, Dec 21, 2007.

  1. kavka

    kavka Member Licensed User


    Help me solve the following problem:

    I have two textboxes. The number of digits in one textbox is two. When I enter the second digit in the first textbox I want that the second textbox gets focused. is that possible?


  2. willisgt

    willisgt Active Member Licensed User

    Sure, it's possible.

    The most logical thing to do would be to catch this with the KeyPress event. There's a problem, though - the KeyPress event gets raised *before* the key you pressed actually gets added to the textbox. At least that's the behavior on my desktop and device.

    So I've been using a little workaround that involves a timer. Create your form, textbox1, textbox2, and timer1.

    In AppStart:

    timer1.interval = 100   ' thats 100 milliseconds
    timer1.enabled = false
    and then:

    sub textbox1_KeyPress( key )
       timer1.enabled = 
    end sub

    sub timer1_Tick
    if StrLength( textbox1.text) >= 2 then textbox2.Focus
       timer1.enabled = 
    end sub
    It comes close to a cheezy hack, but hey, it works for me.


  3. agraham

    agraham Expert Licensed User

    You could use my ControlEvents library that adds "missing" events to B4PPC controls and catch the TextChanged event of the TextBox which occurs after the key press is added. Much better than cheesy hacks :) (Apologies willisgt!)

  4. willisgt

    willisgt Active Member Licensed User

    Cheezy hackers of the world, unite!

  5. kavka

    kavka Member Licensed User

    agraham, can you help me out with this missing events. Do I just copy those three files in the library directory and that is that?
  6. agraham

    agraham Expert Licensed User

    Sounds like you need to learn how to use libraries. You should have downloaded the latest ControlEvents version from either Post #5 (.Net 2.0) or #6 (.NET1.0) from that thread. One of those files is a help file, the chm, the library is the dll - stick the help and the library in the Anywhere Software Libraries folder. Ignore and discard the cs file - you don't need it.

    Restart B4PPC - Desktop. The ControlEvents help should now show under Help - read it and the Main help about libraries.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice