|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
select all text when textbox1 is clickedWhen I select textbox1 I want all text in it to be selected. I used the
textbox1_enter event to run textbox1.selectall() This works if I tab to the box but not if it is selected by clicking on it. I hat to have to put textbox1.selectall() in the click event too. GotFocus event doesn't work any better than the enter event. I could swear that back in VB4 I used the gotfocus event to select all text no matter how the box was entered. Has this changed with .net? Could Hide Selection property be True?
If so, set to false and see if that helps. -Shane Show quoteHide quote "cj" <cj@nospam.nospam> wrote in message news:e5OCzcqUGHA.4956@TK2MSFTNGP09.phx.gbl... > When I select textbox1 I want all text in it to be selected. I used the > textbox1_enter event to run textbox1.selectall() > > This works if I tab to the box but not if it is selected by clicking on > it. I hat to have to put textbox1.selectall() in the click event too. > GotFocus event doesn't work any better than the enter event. I could > swear that back in VB4 I used the gotfocus event to select all text no > matter how the box was entered. Has this changed with .net? Hi cj,
Thanks for your post! Yes, I can reproduce out this behavior. I suspect that certain winform code after the Enter event has cancelled the selection. Regarding this issue, we can call textbox1.selectall() in TextBox.MouseDown event. Hope this helps! Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. cj wrote:
> When I select textbox1 I want all text in it to be selected. I used the Hello cj,> textbox1_enter event to run textbox1.selectall() > > This works if I tab to the box but not if it is selected by clicking on > it. I hat to have to put textbox1.selectall() in the click event too. > GotFocus event doesn't work any better than the enter event. I could > swear that back in VB4 I used the gotfocus event to select all text no > matter how the box was entered. Has this changed with .net? I found the same problem, here's what I have been doing - Don't use .SelectAll() in GotFocus, Enter etc. - .NET forms do this automatically when you Tab to the Control. (Which is what you're seeing already) Now put .SelectAll() in your MouseUp event and everything will work. One advantage I found from using the MouseUp event is that modifications can take place during the GotFocus event (such as removing formatting from text) and the text will still be highlighted at the end. Hope this helps. ShaneO There are 10 kinds of people - Those who understand Binary and those who don't.
Form Exit
Class question Doing some extra task while saving databind Controls in VB.Net 2005 ? Dynamically Loading Programs Adding HTML code to project. SQL Server and ADO.Net best method Auto-stop DUN via VB.Net? Re: ContextSwitchDeadlock was detected set default printer GetType of custom Property set to nothing |
|||||||||||||||||||||||