473,467 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

select all text when textbox1 is clicked

cj
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?
Mar 28 '06 #1
3 2461
Could Hide Selection property be True?

If so, set to false and see if that helps.

-Shane

"cj" <cj@nospam.nospam> wrote in message
news:e5**************@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?

Mar 28 '06 #2
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.

Mar 29 '06 #3
cj wrote:
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?


Hello cj,

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.
Mar 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Dino M. Buljubasic | last post by:
I am trying to build a daily calendar similar to Microsoft Outlook where a user can select hours of a day using mouse. I have a form that holds a panel which contains user controls each...
8
by: cj | last post by:
I asked this question a couple of days ago but am just now looking at it again. I used to use the textbox gotfoucs event to have all the text in the textbox selected when it gotfocus. That...
4
by: Amy | last post by:
I need some help. I have this table with alternate row colors. Class gray and class white. I have javascript that do highlight when mouseover row ... and onclick to select row and highlight it...
4
by: Dabbler | last post by:
Is there a way to mark the text in a TextBox control as selected so when the user types a new value the existing text is replaced? Thanks
2
by: dbfrey | last post by:
This is the oddest thing I've ever seen. We have an aspx page with some user controls, one is a main, another is a status, which has an edit button. on the main control, we have some dropdowns...
8
by: Zytan | last post by:
TextChanged is only called when the user modifes a control's text, not if the program does. How can I make it be called when the program modifies the text? Zytan
3
by: S Moran | last post by:
private void button1_Click(object sender, EventArgs e) { textBox1.SelectionStart = 0; textBox1.SelectionLength = textBox1.Text.Length; } yet when the button is clicked and there is text in...
18
by: nfenlon | last post by:
I'm new to VB express 2005 and am having some trouble with coding. I'm using a CASE structure in my program and i'm wondering if anyone can help me. Instead of Saying "Case 1,2,3,4" is there a way...
8
by: Mehbs | last post by:
I created a very simple form. There are 2 text boxes; 1 for entering account number and other to display its desription. I also placed buttom so when it is clicked, select statement underneath...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.