Form1_KeyDown can't be raised up after navigating DataGrid by KeyBoard's Up/Down Key.
Any solution for this case?
Printable View
Form1_KeyDown can't be raised up after navigating DataGrid by KeyBoard's Up/Down Key.
Any solution for this case?
Add this:
Code:// Add to the Form_Load() Event
this.KeyPreview = true;
Thx for replying, but it's not the solution.
The form's KeyPreview property has been set to be True already.
The Form's KeyDown Event can be raised up.
???But after navigating the DataGrid by UP/DOWN Key,
the Form's KeyDown Event can't be raised up.???
If I click on the DataGrid, the Form's KeyDown Event can be raised up again.
How can I solve this problem?
public class Form1 : System.Windows.Forms.Form, IMessageFilter
{
const int WM_KEYDOWN = 0x100;
public bool PreFilterMessage(ref Message m)
{
Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode;
if(m.Msg == WM_KEYDOWN)
{
...
return true;
}
return false;
}
....
private void Form1_Load(object sender, System.EventArgs e)
{
Application.AddMessageFilter(this);
}
}
These codes run so good to catch the KeyDown action!