Hello I am working on a simple calculator program for school. I already have all the button clicks working, which is all that was required.
I thought it would be cool if I could get it to where you could use the keyboard for entry and I've done similar things with Visual Basic (which I learned in high school).
I looked online and found the syntax (I'm pretty sure its right) but for some reason it's not sensing a keypress event.
This is the code I have right now, I just want to get the keypress working, I already know how to do the specifics inside the event once it is working.
Yea something is odd about your code. If that event method was generated by visual studio, why does it have System.Windows.Forms.KeyEventArgs in the parameters definition. To me this makes me think that Windows.Forms isn't in the namespace which would be odd if that code is in the form.
Keypreview is enabled, I think I said that in my original post, but maybe not. Anyway I am using visual c# express to create this and I got the code for the keypress by using MSDN Here: http://msdn.microsoft.com/en-us/libr...ss.aspx?ppud=4
I couldn't find a way to automatically add in a keypress in visual express. I manually added in the method based upon the msdn example. I am still new to this program, so maybe I just haven't found it yet.
If this isn't what you meant, please let me know and if you know a way to add in the keypress method without manually typing it please let me know.
I guess changing from the properties to events in the bottom right (by default) was missing..
So.. Im gonna take an educated guess you didnt tie the event to the method you made??
I'm not entirely sure what you mean, considering I am still new to making forms in c# (I was introduced to the language last semester where all we did was command line programs) but I think I know what you mean.
If I understand you correctly there is something I have to do to get the method to be called whenever a key is pressed. If so then you are correct I don't have this.
Also the only thing in the bottom (right or left) is the error list when in code view and the properties window in design view.
When yo are in design view and you press the little button with the lightning symbol on it, in the properties window. You get a list of all available events for the control currently selected. Double click the event you want and you will get into the code view in the eventhandler you just doubleclicked. Type in the code you want to do, it will work. The grungy details of the event handling are taken care of in the in the forms.designer.cs class.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.