I am using Microsoft Visual C# 2010 Express to write a Window Form Application. I am writing a Sudoku program. I have written this program once before and got it working. I lost the source code due to a hard drive failure. I got a grid drawn on the form. I got the mouse event to work. I got key press event to work. I then I added several buttons to the form and got them to work. But then a problem occurs. After I added the buttons and got them working, the key press event stops working. Why is there a conflict between the button event and the key press event?
Here is the Code for a demo program that has the same problem. ‘code’ private void doMouseDown(object sender, MouseEventArgs e) { int i; i = 0; }
private void DoKeyPress(object sender, KeyPressEventArgs e)\\ This worked until I added
{
int i;
i = 1;
}
private void doClickButton(object sender, EventArgs e) \\ This
{
int i;
i = 2;
}
‘code’
The mouse event and keypress event was added to the form.
Looks like I need a way to set the focus on the form. The program will need to go back and forth between the mouse and the keyboard before the button is used.