pcf108 Posted October 16, 2003 Posted October 16, 2003 I'm trying to have a textbox select all the text whenever a textbox control gets focus. Code below works when the control gets focus via tab but when clicked it does not. When debugging, this event occurs but nothing happens, possibly because it occurs before the click is processed. Also does not work if I use TextBox1.Click event. Any suggestions?? Private Sub TextBoxEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles TextBox1.Enter DirectCast(sender, TextBox).SelectAll() End Sub Quote
*Experts* Volte Posted October 16, 2003 *Experts* Posted October 16, 2003 Have you tried also handling the Click event to do this? Although traditionally when doing things such as data entry, clicking on the textbox does not cause the text to all be selected. Quote
pcf108 Posted October 22, 2003 Author Posted October 22, 2003 Yes, I tried Click as well as the GotFocus event. I agree that traditionally this is not necessary, but it helps in some places. Quote
pcf108 Posted October 22, 2003 Author Posted October 22, 2003 Deeee... MouseUp event works for this if anyone is interested. Quote
*Experts* Nerseus Posted October 22, 2003 *Experts* Posted October 22, 2003 Why are you having to do this? On my system (Windows XP) this is the default behavior. That is, tabbing into a textbox autoselects everything the first time through. Only on subsequent passes does it change. As Volte pointed out, traditionally, tabbing in should auto-select but clicking should not. For that behavior, using the Enter event would be perfect. But who knows what your users want? I'm glad you found a solution that they like :) -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.