I have a DataGridView
in C# and need to disable the arrow keys (so they cannot navigate the list via keys). I have tried this:
void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyData & Keys.KeyCode)
{
case Keys.Up:
case Keys.Right:
case Keys.Down:
case Keys.Left:
e.Handled = true;
e.SuppressKeyPress = true;
break;
}
}
But it did not disable the arrow keys. Any thoughts?
I tried this handler, but got a compile error:
this.dataGridView1.KeyDown += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_KeyDown);
Error 1 No overload for 'dataGridView1_KeyDown' matches delegate 'System.Windows.Forms.DataGridViewCellEventHandler' Form1.Designer.cs 78 43 FaxMonitorCSharp