CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 1999
    Posts
    29

    Text highlighted

    I want to highlight a text in a Textbox control.
    ¿What may I to make?



  2. #2
    Join Date
    May 1999
    Location
    Oxford UK
    Posts
    1,459

    Re: Text highlighted

    Take a look at the 'SelStart' and other textbox related properties in the VB Help files

    Chris Eastwood

    CodeGuru - the website for developers
    http://www.codeguru.com/vb

  3. #3
    Join Date
    Jun 1999
    Posts
    6

    Re: Text highlighted

    Use the SelLength,SelStart,SelText object properties. The following code will highlight the text in a text box from beginning to end. Just substitute the name of your text box.

    textbox.SelStart = 0
    txtbox.SelLength = len(textbox.Text)




    Cheers for now
    Charlie



  4. #4
    Join Date
    Aug 1999
    Location
    Bahrain
    Posts
    13

    Re: Text highlighted

    Just use the following lines of code. (Assuming the tectbox is called txtName.......


    txtName.SelStart=0
    txtName.SelLength=len(txtName)




    Enjoy........


  5. #5
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    My favorite...

    This is one of my favorites:
    (try this on "click" or even on "gotfocus" event)

    SendKeys "{home}+{end}"




    Michael Vlastos
    Company MODUS SA
    Development Department
    Athens, Greece
    Tel: +3-01-9414900

  6. #6
    Join Date
    Apr 1999
    Posts
    29

    Re: My favorite...

    Thank you very much !


  7. #7
    Join Date
    Apr 1999
    Posts
    29

    Re: Text highlighted

    Thank you very much !


  8. #8
    Join Date
    Aug 1999
    Posts
    3

    Re: Text highlighted

    Autoselect Text
    To make a TextBox automatically select its text when focus enters it, give it a GotFocus event handler like this:
    Private Sub Text1_GotFocus()
    SendKeys "{home}+{end}"
    End Sub
    Or use SelStart and SelLength:
    Private Sub Text1_GotFocus()
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
    End Sub



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