selecting text in the text box
I have a form with text boxs on it
whenever i enter(got focus) the textbox i want the text in it to be get selected
i can use textbox.selstart and textbox.sellenth but have many text boxs(48)
do i have to write it for each and every text box
(using VB net)
Please help
Re: selecting text in the text box
Is there a special trick for when a user clicks into the text box? 'Cause i can't get it to select everything when a user clicks in the text box.
Code:
Private Sub TextBox2_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.Enter
TextBox2.SelectAll()
End Sub
Re: selecting text in the text box
Quote:
Originally Posted by MrGTI
Is there a special trick for when a user
clicks into the text box? 'Cause i can't get it to select everything when a user clicks in the text box.
Code:
Private Sub TextBox2_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.Enter
TextBox2.SelectAll()
End Sub
It does select it. You can copy it to another Text field. It just doesn't highlight it.
Re: selecting text in the text box
Hi,
"tHANKS A LOTS I WILL TRY SELECTALL()"
But you will still have to enter it a lot of times, or put a a lot of handles on.
Matt3011's suggestion means you do not have to write the code more than once.
Re: selecting text in the text box
Any help in figuring out how to highlight the entire text in a TextBox when a user clicks in the text box? :confused:
Nothing i try will highlight the text (when a user clicks into a text box).
Re: selecting text in the text box
Quote:
Originally Posted by MrGTI
Any help in figuring out how to highlight the entire text in a TextBox when a user clicks in the text box? :confused:
Nothing i try will highlight the text (when a user clicks into a text box).
I've had no success with that either, but there must be a way. If we get no joy on this thread I will start a specific one.
Re: selecting text in the text box
Thanks for the reply but one thing u missed that i know the selectall property but my promblem is i have all most 48 - 60 text box on the form and i don't want to repeat the code "Selectall"
Re: selecting text in the text box
Quote:
Originally Posted by sameer spitfire
Thanks for the reply but one thing u missed that i know the selectall property but my promblem is i have all most 48 - 60 text box on the form and i don't want to repeat the code "Selectall"
You have not indicated to which of the replies you are referring.
I repeat:
If you use Matt3011's suggestion you will only have to enter the code once.
Do you object to that?
Re: selecting text in the text box
Quote:
Originally Posted by taxes
I've had no success with that either, but there must be a way. If we get no joy on this thread I will start a specific one.
Hi,
Looks like the ONLY event which doesn't highlight the text when you use SelectAll() is the GotFocus :wave:
Try it in Click, MouseDown, MouseUp etc.
With acknowledgments to Brownmonkey :wave:
Re: selecting text in the text box
The GotFocus/Enter events don't work with SelectAll when you click into the text box. So i created a special procedure that i call from the MouseHover event.