KeyDown Problem
Hello,
I want to capture special Keys from the DataGridView during EditMode (e.g. when the Caret is showing)
This was my first guess:
...somewhere in the code ...
dataGridViewSuche.EditingControl.KeyDown -= new KeyEventHandler(EditingControl_KeyDown);
dataGridViewSuche.EditingControl.KeyDown += new KeyEventHandler(EditingControl_KeyDown);
later...
private void EditingControl_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
BeginSearch(); // special Reaction to "Return"
e.Handled = true;
}
Console.WriteLine(e.KeyCode.ToString()); // just for looking....
}
As i understood, i can not get preprocessed charaters (like vk_return, vk_up ...) like this.
So i adapted a piece of Code made by Ken Tucker...
public override bool PreProcessMessage(ref Message msg)
{
Keys keyCode = (Keys)(int)msg.WParam & Keys.KeyCode;
// for a datagrid, we need to eat the tab key oe else its done twice
if((msg.Msg == WM_KEYDOWN)
&& keyCode == Keys.Enter)
{
...
}
}
It is the same reaction: i catch get the Keys.Enter only if the grid is not in Editing mode.
So i'll never get it if the DataGridViews EditMode is "EditOnEnter".
Any Ideas/Advice ?
Roland

