I am learning C# and am making a calculator. All is going well so far except its driving me mad trying to make it accept keyboard commands.
I have done some testing in another file and can simply add keyboard commands to a textbox or label using the code below in the KeyPress event:
However, for the purposes of a calculator, being able to add all keyboard characters isnt ideal.
I have searched many forums and have seen code like:
But when i try to add e.KeyCode, KeyCode is not an option. Only KeyChar is, which doesnt work.
Anyone know why I cant have KeyCode?
Basically, I trying to write code that adds a numpad keypress to a textbox on a winform.
Thanks
I have done some testing in another file and can simply add keyboard commands to a textbox or label using the code below in the KeyPress event:
C#:
textbox1.Text += e.KeyChar;
However, for the purposes of a calculator, being able to add all keyboard characters isnt ideal.
I have searched many forums and have seen code like:
C#:
if (e.KeyCode == Keys.Numpad1)
{
Entercode here
}
But when i try to add e.KeyCode, KeyCode is not an option. Only KeyChar is, which doesnt work.
Anyone know why I cant have KeyCode?
Basically, I trying to write code that adds a numpad keypress to a textbox on a winform.
Thanks