473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

TextBox.SelectAll() doesn't work w/ Enter Event

VSN03:C#

Create a C# Windows Form project.
Add two TextBox controls.
From the Properties of each, add an Enter Event handler.
In the generated Enter Event Handlers (textBox1_Enter & textBox2_Enter ),
add the code TextBox1.SelectAll(); and TextBox2.SelectAll();
Run the App.

When you run the app with a breakpoint at textBox1_Enter(), and
MOUSE to a field, the handler hits, executes SelectAll()
and nothing happens.

Bottom line: The event "hits" and SelectAll() does nothing.

If you TAB from field to field it works fine. The SelectAll
only fails when you MOUSE to a field. I believe that what is
happening is that the text is being selected and then
immediately repainted. My machine is too fast to see it.

Trying GotFocus is no help. Using the mouse events is out of
the question. It will interfere with normal selection.

In searching I've seen a number of complaints revolving around
this issue (none of which were implemented this way) and so
far I have turned up no solutions.

This should be easy to do, but how?

regards

bullshark

Nov 15 '05 #1
2 15580
The fact is that Enter and GotFocus events are fired _before_ any mouse
action is processed. Try this: TAB into a text box (and the text gets
selected) and _then_ click into the text (and the text gets _deselected_).
That's exactly what happens when you mouse-click into the box - 1) Enter
gets fired; 2) text gets selected by .SelectAll; 3) Mouse click (mousedown?)
gets processed by the textbox and the text gets deselected.

"bullshark" <bu*******@scubadiving.com> wrote in message
news:mn********************************@4ax.com...
VSN03:C#

Create a C# Windows Form project.
Add two TextBox controls.
From the Properties of each, add an Enter Event handler.
In the generated Enter Event Handlers (textBox1_Enter & textBox2_Enter ),
add the code TextBox1.SelectAll(); and TextBox2.SelectAll();
Run the App.

When you run the app with a breakpoint at textBox1_Enter(), and
MOUSE to a field, the handler hits, executes SelectAll()
and nothing happens.

Bottom line: The event "hits" and SelectAll() does nothing.

If you TAB from field to field it works fine. The SelectAll
only fails when you MOUSE to a field. I believe that what is
happening is that the text is being selected and then
immediately repainted. My machine is too fast to see it.

Trying GotFocus is no help. Using the mouse events is out of
the question. It will interfere with normal selection.

In searching I've seen a number of complaints revolving around
this issue (none of which were implemented this way) and so
far I have turned up no solutions.

This should be easy to do, but how?

regards

bullshark

Nov 15 '05 #2
> PS - some website "developersdex.com" is harvesting names
from the NG and spamming membership/views for their page.
Are you a part of that? Please don't do it anymore.


Are you talking to yourself?
Nov 15 '05 #3

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

Similar topics

7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
6
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: ...
1
by: nousha | last post by:
hi everybody, i have a dropdownlist in web application but it doesnt work if anybody met this problem before plz help me
3
by: Clouds | last post by:
Hi ! How do I add the dynamic event handler for a dropdownlist present in the itemtemplate of a datalist !! I am doing it in the itemdatabound event of the datalist but it doesnt work... I am...
1
by: theinvisibleGhost | last post by:
Is there an underlying interface anywhere that .NET form controls use to include the Enter, Leave, GotFocus, and LostFocus events? I have a problem where I've got a usercontrol which is being...
0
by: Juna | last post by:
I have been working in vs2003, but now started to work in vs2005 but the problem, I have simple web application not website, which work i mean open in browser when we press F5 or run the...
2
by: PR | last post by:
Hello, I have a bunch of textboxes on my form, and I would very much like it if their text could be automatically selected when each one is entered. I've tried code like this: Private Sub...
0
by: Rainer Queck | last post by:
Hello NG, the hint on the property editor for the Form "Enter" event sais: Gets fired, if this control gets the active control. In my application I experience, that this is "mostly" true, but...
4
by: ronakinuk | last post by:
hello i need help in this please. i dont have much knowledge of VBA but can do very basic things by learning from different forums. i want to create one excel application where there will be few...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.