Click to See Complete Forum and Search --> : Text highlighted


Federica Pavese
August 13th, 1999, 11:12 AM
I want to highlight a text in a Textbox control.
¿What may I to make?

Chris Eastwood
August 13th, 1999, 01:46 PM
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

C Acheson-Crow
August 13th, 1999, 05:10 PM
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

Naweed Akram
August 14th, 1999, 01:24 AM
Just use the following lines of code. (Assuming the tectbox is called txtName.......


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




Enjoy........

Dr_Michael
August 16th, 1999, 01:52 AM
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

Federica Pavese
August 17th, 1999, 07:22 AM
Thank you very much !

Federica Pavese
August 17th, 1999, 07:34 AM
Thank you very much !

shallowborne
August 20th, 1999, 11:04 PM
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