By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,943 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,943 IT Pros & Developers. It's quick & easy.

keypress event help!!

P: 1
I'm making a calculator in C# and i have a keypress event set up. It works and all I just want to know if theres a way to not display what key i press in the textbox. Thanks :)
Jan 20 '09 #1
Share this Question
Share on Google+
4 Replies

Expert 5K+
P: 7,872
Cancel the event in the event handler using the args
Jan 20 '09 #2

P: 7
Implement your own event to handler to handle key press event. then call parent key event handler and return false so that it won't display ur keystroke.
Jan 21 '09 #3

P: 7
sorry for the last reply. it won't work in C#. i was thinking about some other programming language and mentioned it in previously reply.
Actual thing will something like below:

For example you want to suppress the key "i"
private void Form1_KeyDown(object sender, KeyEventArgs e)
if (e.KeyCode != Keys.i)
textbox1.Text = e.KeyCode;
// Don't pass message to other controls
e.Handled = true;
Jan 21 '09 #4

P: 39
If you make the set the textbox ReadOnly Property to true, it will allow you to set the text programmatically while not allow users to enter text.
Jan 22 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.