Click here to Skip to main content
15,885,032 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Select all of the text in a textbox Pin
Dave Kreskowiak15-May-07 4:17
mveDave Kreskowiak15-May-07 4:17 
GeneralRe: Select all of the text in a textbox Pin
Marcus J. Smith15-May-07 5:45
professionalMarcus J. Smith15-May-07 5:45 
AnswerRe: Select all of the text in a textbox Pin
TwoFaced15-May-07 4:22
TwoFaced15-May-07 4:22 
GeneralRe: Select all of the text in a textbox Pin
Dave Kreskowiak15-May-07 4:30
mveDave Kreskowiak15-May-07 4:30 
GeneralRe: Select all of the text in a textbox Pin
Marcus J. Smith15-May-07 5:44
professionalMarcus J. Smith15-May-07 5:44 
GeneralRe: Select all of the text in a textbox Pin
TwoFaced15-May-07 5:55
TwoFaced15-May-07 5:55 
GeneralRe: Select all of the text in a textbox Pin
Dave Kreskowiak15-May-07 6:01
mveDave Kreskowiak15-May-07 6:01 
GeneralRe: Select all of the text in a textbox [modified] Pin
TwoFaced15-May-07 5:53
TwoFaced15-May-07 5:53 
Actually you don't need to override the click event to get select all to work. The click event fires late enough that select all will work just fine when added to that event. I mis-spoke in my post. The problem wasn't selecting all when the user clicks a textbox. The problem was selecting all when the textbox gets focus ie. The Internet explorer address bar. I believe this is what the OP wants. Currently if the textbox got focus by the user clicking on it the highlighting would be undone by the click. Tabbing worked just fine however.

The focus event unfortunatly fires to early causing the select all to be undone (again only when clicked). Delaying the select all was the easiest solution as far as I could tell.

You could also respond to the click event which fires late enough but clearly we don't want to select all on every click. So you need a global boolean to see if the textbox just recieved focus, which would be the only time you'd want to select all. Unfortunatly because we are handling this in the click event we aren't handling the focus recieved by tabbing. Thus additional code would be required in the focus event also. The delayed approach to me seemed the most straight forward and cleanest. Plus it had the added benefit of easily being able to handle one or multiple textboxes even if a custom textbox wasn't going to be created. If I missed the obvious please let me know. But the delayed method just seemed cleanest in my opinion and was just as trivial to pull off.


-- modified at 12:00 Tuesday 15th May, 2007
GeneralRe: Select all of the text in a textbox Pin
Dave Kreskowiak15-May-07 6:08
mveDave Kreskowiak15-May-07 6:08 
GeneralRe: Select all of the text in a textbox Pin
TwoFaced15-May-07 6:28
TwoFaced15-May-07 6:28 
GeneralRe: Select all of the text in a textbox Pin
Dave Kreskowiak15-May-07 6:30
mveDave Kreskowiak15-May-07 6:30 
GeneralRe: Select all of the text in a textbox - Windows app Pin
Marcus J. Smith15-May-07 6:15
professionalMarcus J. Smith15-May-07 6:15 
GeneralRe: Select all of the text in a textbox [modified] Pin
Dave Kreskowiak15-May-07 6:20
mveDave Kreskowiak15-May-07 6:20 
GeneralRe: Select all of the text in a textbox Pin
TwoFaced15-May-07 6:38
TwoFaced15-May-07 6:38 
GeneralRe: Select all of the text in a textbox Pin
Dave Kreskowiak15-May-07 6:55
mveDave Kreskowiak15-May-07 6:55 
AnswerRe: Select all of the text in a textbox [modified] Pin
Xandip15-May-07 19:16
Xandip15-May-07 19:16 
QuestionDelegates are type-safe Function Pointers Pin
Sonia Gupta15-May-07 2:34
Sonia Gupta15-May-07 2:34 
AnswerRe: Delegates are type-safe Function Pointers Pin
Colin Angus Mackay15-May-07 2:37
Colin Angus Mackay15-May-07 2:37 
Questiondelegates Pin
Sonia Gupta15-May-07 2:28
Sonia Gupta15-May-07 2:28 
AnswerRe: delegates Pin
Colin Angus Mackay15-May-07 2:35
Colin Angus Mackay15-May-07 2:35 
QuestionRe: delegates Pin
Sonia Gupta15-May-07 2:48
Sonia Gupta15-May-07 2:48 
AnswerRe: delegates Pin
Guffa15-May-07 3:50
Guffa15-May-07 3:50 
AnswerRe: delegates Pin
Colin Angus Mackay15-May-07 3:51
Colin Angus Mackay15-May-07 3:51 
QuestionRaising and handling events in 2 independant forms. Pin
steve_rm15-May-07 1:51
steve_rm15-May-07 1:51 
AnswerRe: Raising and handling events in 2 independant forms. Pin
Probeer Das15-May-07 3:32
Probeer Das15-May-07 3:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.