473,587 Members | 2,321 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I suppress the KeyChar in a KeyPress event?

I am trying to trap on a keypress "+" event and convert it to a tab for a
high-speed dataentry form that is done entirely from a 10-key. However, I do
NOT want the "+" character to be passed on to the textbox.

I am using code similar to this:

public class FastEntryContro l : TextBox
{
protected override void OnKeyPress(KeyP ressEventArgs e)
{
if ( (char)'+' == e.KeyChar )
//This is to create the tab event... but the "+" is still being entered
into the current textbox before the tab
base.OnKeyPress ( new KeyPressEventAr gs ( '\t');
else
base.OnKeyPress ( e);
}
Nov 15 '05 #1
1 4859
Top Gun <nf*@nospam.com > wrote:
I am trying to trap on a keypress "+" event and convert it to a tab for a
high-speed dataentry form that is done entirely from a 10-key. However, I do
NOT want the "+" character to be passed on to the textbox.


Set e.Handled to true to suppress further processing of the event.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2

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

Similar topics

4
5091
by: Rockfrdcpl | last post by:
I am trying to use statements like "Select Case Asc(e.KeyChar)" in a sub routine that is in a module that I call from different forms so I don't have to type the series of statements several times in my program but I haven't figured out the exact code to make it work. The program says I need an instance of it but I can't seem to get it to...
0
1733
by: Wiktor Zychla | last post by:
in my application I sometimes use KeyPress event. in the event handler I have to check the char the user is trying to type. in NTs everything is correct. however on W98 I've noticed that the character given in e.KeyChar (e is KeyPressEventArgs of course) is NOT correctly converted ToString() when I type polish specific letters! instead...
3
14825
by: Baz | last post by:
Hi All, In VB6, I had text boxes which, in I wanted to allow numeric data only. To do this, I put some code in the KeyPress event of the control, and if the key that was entered was outside the range of 0-9, then I reset the KeyAscii prperty to 0. Thus: Private Sub tTransactionAmount_KeyPress(KeyAscii As Integer) If Keyascii < 48 Or...
4
4521
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...
15
4028
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...
5
2877
by: papalarge | last post by:
I've noticed that Ctrl+i creates a Tab, whereas I'd like to make it italicize instead. My code is as follows Private Sub txtPrivate_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPrivate.KeyDown 'IF CTRL WAS PRESSED If e.Control Then 'IF "I" WAS PRESSED TOO If e.KeyCode = Keys.i Then If...
4
9944
by: =?Utf-8?B?UmljaA==?= | last post by:
When I press the Enter key in a Textbox I get a beep sound. But when I press the Enter key in a combobox, I don't get the beep sound. Is there a way to suppress the beep? How to do this? Thanks
7
10830
by: tekeste | last post by:
Private Sub combobox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles cmbcombobox1.KeyPress If Asc(e.KeyChar) = Keys.Enter Then textbox2.Focus() End If End Sub i want just press enter key to go to the next textbox2 after selecting combobox1, but it's not working. it...
2
19284
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.
0
7918
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7843
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...
1
7967
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...
0
6621
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5713
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...
0
5392
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...
0
3840
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...
0
3875
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2353
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.