Answered by:
highlighting text in a textbox

Question
-
I had a simple function written in VB 6 for selecting all the text in a textbox when it got focus. Does anyone know how to to the same in VB 2005.
Public Sub Highlight()
With Screen.ActiveForm
If (TypeOf .ActiveControl Is TextBox) Then
.ActiveControl.SelStart = 0
.ActiveControl.SelLength = Len(.ActiveControl)
End If
End With
End Sub
The SelStart and SelLength methods don't appear to exist in VB.Net.Thursday, April 12, 2007 1:43 PM
Answers
-
Hi,
TextBox1.SelectAll() function works.
Thanks,
Ch.T.Gopi Kumar.
Thursday, April 12, 2007 1:59 PM -
Two quork about textbox...
If the textbox doesn't have focus the selection doesn't show....
If you click on a textbox the selection disapears and cursor appears at click position.... (The default way it should be..)
Thursday, April 12, 2007 2:05 PM
All replies
-
in the gotfocus event
me.textbox1.select(0,me.textbox1.text.length)
or
me.textbox1.selectall
Thursday, April 12, 2007 1:54 PM -
Hi,
TextBox1.SelectAll() function works.
Thanks,
Ch.T.Gopi Kumar.
Thursday, April 12, 2007 1:59 PM -
Two quork about textbox...
If the textbox doesn't have focus the selection doesn't show....
If you click on a textbox the selection disapears and cursor appears at click position.... (The default way it should be..)
Thursday, April 12, 2007 2:05 PM