|
-
Dec 29th, 2002, 09:45 PM
#1
Thread Starter
Lively Member
Form's KeyDown Event
Form1_KeyDown can't be raised up after navigating DataGrid by KeyBoard's Up/Down Key.
Any solution for this case?
-
Dec 29th, 2002, 10:39 PM
#2
PowerPoster
Add this:
Code:
// Add to the Form_Load() Event
this.KeyPreview = true;
-
Dec 30th, 2002, 12:43 AM
#3
Thread Starter
Lively Member
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?
-
Jan 9th, 2003, 10:57 PM
#4
Thread Starter
Lively Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|