TextBox - SelectAll() Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ProgrammingStudent
    New Member
    • Feb 2008
    • 4

    TextBox - SelectAll() Problem

    I have one text box where I enter a number. I can either click the calculate button or use the accept property (enter) to perform the calculation and display the answer in a label.

    I use the SelectAll() method to select the number in the text box when it has the focus.

    When I use the calculate button is works correctly but when I just hit enter the text box has the focus but the number is not selected.

    What could I be doing wrong?
  • daniel aristidou
    Contributor
    • Aug 2007
    • 494

    #2
    Originally posted by ProgrammingStud ent
    I have one text box where I enter a number. I can either click the calculate button or use the accept property (enter) to perform the calculation and display the answer in a label.

    I use the SelectAll() method to select the number in the text box when it has the focus.

    When I use the calculate button is works correctly but when I just hit enter the text box has the focus but the number is not selected.

    What could I be doing wrong?
    Um the problem is probably in the event you entered the code.
    Try using the (either/or both) click event and the got focus event

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      A couple of questions to help clarify the situation...
      - What version of VB are you using?
      - How are you intercepting the Enter?

      Comment

      • debasisdas
        Recognized Expert Expert
        • Dec 2006
        • 8119

        #4
        You need to handle the key down event .

        Comment

        Working...