Don't Tab to next box on enter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • desertavataraz
    New Member
    • Jan 2009
    • 14

    Don't Tab to next box on enter

    I am trying to find out how to retain focus on a button if you use enter to activate a click event on the button. When you hit the enter key, the focus should stay on the button until you hit tab, but presently, it jumps to the next button.
    I would post some of my code, but none of my attempts even came close to working, so I am at a loss as to were to even begin. It is probably some simple two-line piece of code that I am unaware of . . . .
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    in the button.click event handler do everything you need to handle then finish with

    ((Button)sender ).Focus();

    Comment

    • desertavataraz
      New Member
      • Jan 2009
      • 14

      #3
      Thanks

      That worked. . . . and from a fellow Arizonian, at that!
      I tried ((btnFind)sende r).Focus(); but it did not like the
      paranthesis or the semicolon, so I just did btnFind.focus and it
      worked like a charm! Thanks again.

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        but it did not like the
        paranthesis or the semicolon
        Sorry... I didn't see that the original post was VB. I gave you C#, but you seemed to have translated it just fine. Cool.

        Comment

        Working...