I want to highlight a text in a Textbox control.
¿What may I to make?
Printable View
I want to highlight a text in a Textbox control.
¿What may I to make?
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
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
Just use the following lines of code. (Assuming the tectbox is called txtName.......
txtName.SelStart=0
txtName.SelLength=len(txtName)
Enjoy........
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
Thank you very much !
Thank you very much !
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