team2005
asked on
How to highlite text using Visual Studio 2008
Hi!
Have this app in Visual Studio 2008. VB.NET
And want to highlight a textbox, when the object got focus.
Insert this line into Gotfocus event....
Text1.SelectionStart = 0
Text1.Select(0, Text1.Text.Length)
But it dosen work ???
Please help ASAP.
Have this app in Visual Studio 2008. VB.NET
And want to highlight a textbox, when the object got focus.
Insert this line into Gotfocus event....
Text1.SelectionStart = 0
Text1.Select(0, Text1.Text.Length)
But it dosen work ???
Please help ASAP.
ASKER
Hi!
No, dosent work ???
No, dosent work ???
Sorry, was testing the selction from a button event and not got foucs. Problem seems to be that when you click the box the mouse event is triggered and the selection in the gotfocus is removed.
You could simple put
Textbox1.SelectAll() in the MouseUp event for the text box
You could simple put
Textbox1.SelectAll() in the MouseUp event for the text box
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Very good, workink now. Thanks
Your most welcome
Glad I could help!
Regards
Steve
Glad I could help!
Regards
Steve
If TextBox1.SelectionLength = 0 Then
TextBox1.SelectionStart = 0
TextBox1.SelectionLength = TextBox1.TextLength
TextBox1.Select()
End If
Regards
Steve