473,774 Members | 2,218 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Keypress in a textbox.

I am using Visual Studio 2003 to develop a windows application in which I
allow the users to just press Enter, while the focus is on a textbox, in
order to perform a search. My problem is that sometimes Keypress event
stops being raised. I have found that I can reproduce this behavior by
performing a search, opening up another form, then trying to perform another
search. The second search will NEVER work.

How can I fix this problem?

Thanks,
Todd Sparks
Nov 21 '05 #1
12 6544
I think we will need some simplified code that demonstrates the problem to
help you out.

Chris

"Todd Sparks" <co*******@nosp am.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I am using Visual Studio 2003 to develop a windows application in which I
allow the users to just press Enter, while the focus is on a textbox, in
order to perform a search. My problem is that sometimes Keypress event
stops being raised. I have found that I can reproduce this behavior by
performing a search, opening up another form, then trying to perform
another search. The second search will NEVER work.

How can I fix this problem?

Thanks,
Todd Sparks

Nov 21 '05 #2
Here is the code that I am using.

Private Sub customerNumberS earch(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles txtCustomerNumb er.KeyPress
If e.KeyChar = Chr(13) Then
'do search
End If
End Sub
"Chris, Master of All Things Insignificant" <chris@No_Spam_ Please.com> wrote
in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
I think we will need some simplified code that demonstrates the problem to
help you out.

Chris

"Todd Sparks" <co*******@nosp am.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I am using Visual Studio 2003 to develop a windows application in which I
allow the users to just press Enter, while the focus is on a textbox, in
order to perform a search. My problem is that sometimes Keypress event
stops being raised. I have found that I can reproduce this behavior by
performing a search, opening up another form, then trying to perform
another search. The second search will NEVER work.

How can I fix this problem?

Thanks,
Todd Sparks


Nov 21 '05 #3
That does not give me enough information to reproduce the error.

Chris

"Todd Sparks" <co*******@nosp am.nospam> wrote in message
news:ev******** ******@TK2MSFTN GP14.phx.gbl...
Here is the code that I am using.

Private Sub customerNumberS earch(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles txtCustomerNumb er.KeyPress
If e.KeyChar = Chr(13) Then
'do search
End If
End Sub
"Chris, Master of All Things Insignificant" <chris@No_Spam_ Please.com>
wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
I think we will need some simplified code that demonstrates the problem to
help you out.

Chris

"Todd Sparks" <co*******@nosp am.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
I am using Visual Studio 2003 to develop a windows application in which I
allow the users to just press Enter, while the focus is on a textbox, in
order to perform a search. My problem is that sometimes Keypress event
stops being raised. I have found that I can reproduce this behavior by
performing a search, opening up another form, then trying to perform
another search. The second search will NEVER work.

How can I fix this problem?

Thanks,
Todd Sparks



Nov 21 '05 #4
Does the second form you're bringing up have a button that is the form's
default? That might be stealing your keypress event so it's never raised.

Brian

--
Brian Schwartz
FishNet Components
http://www.fishnetcomponents.com
Building better tools for developers--be part of it!
Nov 21 '05 #5
When you say opening up another form, do you mean another instance of
the same form?

Aaron

Todd Sparks wrote:
Here is the code that I am using.

Private Sub customerNumberS earch(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles txtCustomerNumb er.KeyPress
If e.KeyChar = Chr(13) Then
'do search
End If
End Sub
"Chris, Master of All Things Insignificant" <chris@No_Spam_ Please.com> wrote
in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
I think we will need some simplified code that demonstrates the problem to
help you out.

Chris

"Todd Sparks" <co*******@nosp am.nospam> wrote in message
news:%2****** **********@TK2M SFTNGP09.phx.gb l...
I am using Visual Studio 2003 to develop a windows application in which I
allow the users to just press Enter, while the focus is on a textbox, in
order to perform a search. My problem is that sometimes Keypress event
stops being raised. I have found that I can reproduce this behavior by
performing a search, opening up another form, then trying to perform
another search. The second search will NEVER work.

How can I fix this problem?

Thanks,
Todd Sparks



--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #6
I think Brian's hit the nail on the head.

Nov 21 '05 #7
Hi

I agree with Brian's suggestion.
Also I can not reproduce the problem with the code below.
Private Sub customerNumberS earch(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles txtCustomerNumb er.KeyPress
If e.KeyChar = Chr(13) Then
dim fm as new form
fm.show
End If
End Sub

You may have a try and it is better to provide a reproduce sample.
Thanks.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #8
Todd,
When you test this, than it is maybe easier when you want to emulate
situoations which takes a time to try just routines as

Private Sub customerNumberS earch(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles txtCustomerNumb er.KeyPress
If e.KeyChar = Chr(13) Then
threading.threa d.sleep(7000)
End If
End Sub
That gives you in my opinion more the change to isolate your problem.

Just as idea

Cor

"Todd Sparks" <co*******@nosp am.nospam>
...
I am using Visual Studio 2003 to develop a windows application in which I
allow the users to just press Enter, while the focus is on a textbox, in
order to perform a search. My problem is that sometimes Keypress event
stops being raised. I have found that I can reproduce this behavior by
performing a search, opening up another form, then trying to perform
another search. The second search will NEVER work.

How can I fix this problem?

Thanks,
Todd Sparks

Nov 21 '05 #9
No, just opening up another form in my project.

At this point, I have been trying to use a process of elimination to
determine what is causing the problem. I have been removing steps from the
process and trying to determine which step causes the functionality to
break. Right now it seems to have something to do with the fact that when I
return to my 'main' form and change my search criteria and press the Enter
key it is trying to do the button-click that opened up the second form
instead of my search. Any ideas on how I can prevent this action?
"Aaron Smith" <th**********@s mithcentral.net > wrote in message
news:t1******** ***********@new ssvr33.news.pro digy.com...
When you say opening up another form, do you mean another instance of the
same form?

Aaron

Todd Sparks wrote:
Here is the code that I am using.

Private Sub customerNumberS earch(ByVal sender As Object, ByVal e As
System.Windows. Forms.KeyPressE ventArgs) Handles
txtCustomerNumb er.KeyPress
If e.KeyChar = Chr(13) Then
'do search
End If
End Sub
"Chris, Master of All Things Insignificant" <chris@No_Spam_ Please.com>
wrote in message news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
I think we will need some simplified code that demonstrates the problem
to help you out.

Chris

"Todd Sparks" <co*******@nosp am.nospam> wrote in message
news:%2***** ***********@TK2 MSFTNGP09.phx.g bl...

I am using Visual Studio 2003 to develop a windows application in which
I allow the users to just press Enter, while the focus is on a textbox,
in order to perform a search. My problem is that sometimes Keypress
event stops being raised. I have found that I can reproduce this
behavior by performing a search, opening up another form, then trying to
perform another search. The second search will NEVER work.

How can I fix this problem?

Thanks,
Todd Sparks


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #10

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

Similar topics

3
7379
by: Darryn Ross | last post by:
Hi, I am trying to catch the KeyPress event on my datagrid but it isn't working... i have also tried registering the handler with the event like this... dgGLBatch.KeyPress += new KeyPressEventHandler(dgGLBatch_KeyPress); but nothing changed. I was wondering wether a custom table and column style might have an effect on how this works???
0
4281
by: Steph. | last post by:
Hi, I have made a new custom TextBox control to enable ENTER and TAB keys to be trapped in the "KeyPress" and "KeyDown" Events. to do that I have overridden the "IsInputKey" property in my new control (derived from the TextBox control)(see code below). I can now manage the KeyPress/Down event raised by TAB and ENTER keys, but I have one problem : A sound (ding) is played by my computer every time I press the TAB or ENTER key in...
0
2629
by: Hal Gibson | last post by:
Because of a legacy (originally DOS) Sub Procedure "AlphaInput" that is called in thousands of places in our code, I need to be able to set a variable, "KeyedString",to the value of TextBox.Text (KeyedString originally was set by tracking each individual key pressed, independently of textbox.text) Since we're setting KeyedString during the keypress event, Textbox.Text is always one character behind.
4
4533
by: Tom | last post by:
I have a VB.NET user control that I wrote - this control has three or four other controls on it (textbox, combobox, datetime picker, etc). Now, whenever the control is on a form and the user enters anything into the textbox (for instance) I trap the keypress event to handle some stuff (i.e. if it is an enter key, etc). Now, once I am done with handling the keypress event for the textbox, I then need to pass that keypress event BACK to the...
15
4056
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 CALLING FORM! This is very bad for me, because in my application, Form1 responds to an ENTER keypress by calling Form2. If the user closes Form2 via an ENTER, then Form1 just reopens it again, kind of trapping the user in Form2 (they can still close...
3
6864
by: Fia | last post by:
Hi In Visual Basic 6 I could call keypress with an integer of a choosen key. For example I could call a textbox's keypress with the number 13 (for the enter key). But now in Visual Basic .Net I don't know how I shall do to do the same thing. I have tried to send Keys.Numpad8, but then it complains about it cannot convert from Keys to keyEventArgs I have also tried to send the number 8, but then it complains it cannot convert from Integer...
5
3082
by: Henry Jones | last post by:
I am new to C# and wanted to capture the KeyPress for a textbox. I created some code as follows: private void textBox3_KeyPress(object sender, System.EventArgs e) { this.textBox2.Text = sender.ToString();
3
2133
by: windy | last post by:
I got a question about keypress event on textbox: I found that the keypress event doesn't invoked when i press the "." button on alphabetic keyboard, however if i use numberpad's "." button keypress event is invoked. Any idea and solutions? Thanks.
2
19297
by: Tony Johansson | last post by:
Hello! I have created a Control that consist of a label and a textbox.I have called this class ctlLabelTextbox. public partial class ctlLabelTextbox : UserControl { .... } The class that I have created for this purpose is derived from class UserControl.
2
6278
by: Jason Huang | last post by:
Hi, How do I override a TextBox's KeyPress evnt? And how do we use it? Thanks for help. Jason
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10046
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9915
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7463
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6717
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5358
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4014
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 we have to send another system

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.