CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2001
    Location
    British Columbia, Canada
    Posts
    19

    Text Box Property?

    I have a series of small text boxes that I'm using to enter numerical data on a form. I want to be able to change the data quickly as I tab through them, so I'm looking for a way to have the text automatically highlight when it's text box recieves the focus. How can I do this?

    Thank you for all your help.





    The more you know, the more you know you don't know.
    The more you know, the more you know you don't know.

  2. #2
    Join Date
    May 2001
    Location
    Canada
    Posts
    182

    Re: Text Box Property?

    Private Sub txtYourTextBox_GotFocus()
    txtYourTextBox.SelStart = 0
    txtYourTextBox.SelLength = Len(txtYourTextBox.Text)
    End Sub


    Regards,

    Michi
    MCSE, MCDBA

  3. #3
    Join Date
    Jul 2001
    Location
    British Columbia, Canada
    Posts
    19

    Re: Text Box Property?

    Ummm... That sort of worked. It highlighted the contents of the text boxes alright, but it won't let me enter more than one integer now, because the content is continually highlighted. Is that because I'm using the GotFocus event? hmmm... any ideas?





    The more you know, the more you know you don't know.
    The more you know, the more you know you don't know.

  4. #4
    Join Date
    Jul 2001
    Location
    British Columbia, Canada
    Posts
    19

    Re: Text Box Property?

    Nevermind. I made a stupid mistake. I had it set to the Change event instead of GotFocus. That code works just fine. Thank you.





    The more you know, the more you know you don't know.
    The more you know, the more you know you don't know.

  5. #5
    Join Date
    May 2001
    Location
    Canada
    Posts
    182

    Re: Text Box Property?

    It works fine for me. I guess maybe the MaxLength property of this TextBox is set to 1. If so, try to change it to 0 or whatever you want.

    Regards,

    Michi
    MCSE, MCDBA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured