473,490 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Enter Key in a TextBox

Hello:
I'm trying to execute a function when the user press Enter key in a TextBox.
But something is happening in my form because after pressing a button, when
I press the Enter key in the TextBox, the application executes the click
event of the last button selected instead of the keypress event of the
TextBox. Any key event happen in my form, even the keypreview event is
ignored. The propertie AcceptsReturn is set to false and AcceptButton to
none.
I can't understand the reason.

Thanks in advance for your help

Best regards
Nov 16 '05 #1
3 19687
Clicking a button gives it input focus. Try adding this.textBox1.Focus() at
the bottom of your button handler to set the input focus back to your
textBox1.

===================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools

"Jose Egea" <je***@innovem.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello:
I'm trying to execute a function when the user press Enter key in a TextBox. But something is happening in my form because after pressing a button, when I press the Enter key in the TextBox, the application executes the click
event of the last button selected instead of the keypress event of the
TextBox. Any key event happen in my form, even the keypreview event is
ignored. The propertie AcceptsReturn is set to false and AcceptButton to
none.
I can't understand the reason.

Thanks in advance for your help

Best regards

Nov 16 '05 #2
Hi Peter:
I guess it has, because I'm typing into the textbox.
Is there another possibility?


"Peter Jausovec" <Peter Ja******@discussions.microsoft.com> escribió en el
mensaje news:47**********************************@microsof t.com...
Jose,

Are you sure that TextBox control has focus ?

"Jose Egea" wrote:
Hello:
I'm trying to execute a function when the user press Enter key in a TextBox. But something is happening in my form because after pressing a button, when I press the Enter key in the TextBox, the application executes the click
event of the last button selected instead of the keypress event of the
TextBox. Any key event happen in my form, even the keypreview event is
ignored. The propertie AcceptsReturn is set to false and AcceptButton to
none.
I can't understand the reason.

Thanks in advance for your help

Best regards

Nov 16 '05 #3
Thanks for your answer, but after investigating a little more I have
discovered that the issue is around mdi forms that I'm using in this
application.
I have a MDI child form that open another MDI child form this way when I
press a button:
private void button1_Click(object sender, System.EventArgs e)
{
fChild2=new frmChild2();
fChild2.MdiParent=this.MdiParent ;
fChild2.Show();
}

When I close this second child form and the first child form recover the
focus, if I got into a textbox of that first child form and press Enter key
the click button event fires instead of the key press event.
I have checked that the focus in in the textbox when I press the Enter.
I have a small project to check the effect.

Is there any explanation?
Thanks for your help again.

Best regards

"ClayB [Syncfusion]" <cl***@syncfusion.com> escribió en el mensaje
news:uT**************@TK2MSFTNGP09.phx.gbl...
Clicking a button gives it input focus. Try adding this.textBox1.Focus() at the bottom of your button handler to set the input focus back to your
textBox1.

===================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools

"Jose Egea" <je***@innovem.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hello:
I'm trying to execute a function when the user press Enter key in a

TextBox.
But something is happening in my form because after pressing a button,

when
I press the Enter key in the TextBox, the application executes the click
event of the last button selected instead of the keypress event of the
TextBox. Any key event happen in my form, even the keypreview event is
ignored. The propertie AcceptsReturn is set to false and AcceptButton to
none.
I can't understand the reason.

Thanks in advance for your help

Best regards


Nov 16 '05 #4

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

Similar topics

10
4366
by: Deano | last post by:
I think that just about sums it up. Is there a fix/workaround for this?It's quite annoying behaviour and not user-friendly.thanksMartin
7
37925
by: deko | last post by:
I have a textbox in a form into which users enter a string to execute a search. After the user presses Enter, I'd like the focus to go back to the textbox, but the default behavior of the Enter...
5
6799
by: Steve | last post by:
Hi, Is it possible to make hitting the enter key in an ASP textbox run the code behind an ASP button on a form? I have a search page which users tend to type in the query then just hit enter...
5
1914
by: Girish | last post by:
I have TWO submit buttons of type IMAGE on my asp form. This renders as <input type="image">. I need to be able to eble the ENTER button for both buttons. Yes, I know that for the input type...
15
4006
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
0
1809
by: Tom Edelbrok | last post by:
I'm using VS 2005 to develop an intranet asp.net web application and I get a weird situation. If I start out with any ASPX page that contains an ImageButton control followed by a TextBox control,...
7
3151
by: Marc | last post by:
Hi, I want my user to be able to rename a button control by selcting rename from a menu. This then opens a text box in which to enter the new name in. I want the button control to...
4
7605
by: nkoier | last post by:
Hi, I've been going crazy trying to figure out what's wrong with our Asp.Net 2.0 intranet site. At the very top of our main page I provide a TextBox and a Button for submitting Google searches....
1
6957
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the...
6
3574
by: Mark B | last post by:
I have a function that looks up a SQL table to see if a search term matches. It works fine but so far there are two things yet to work: 1) After entering a search term and pressing Enter, nothing...
0
7108
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
6967
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
7142
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
7352
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
4565
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
3078
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
1383
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 ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.