protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Enter) //监听回车事件
{
if (this.dataGridView2.IsCurrentCellInEditMode) //如果当前单元格处于编辑模式
{
if (this.dataGridView2.CurrentCell.ColumnIndex == 0)
{
SendKeys.Send("{RIGHT}");
SendKeys.Send("{RIGHT}");
return true;
}
else if (this.dataGridView2.CurrentCell.ColumnIndex == 2)
{
SendKeys.Send("{Down}");
SendKeys.Send("{LEFT}");
SendKeys.Send("{LEFT}");
return true;
}
}
else
{
if (this.dataGridView2.CurrentCell.ColumnIndex == 0)
{
SendKeys.Send("{RIGHT}");
SendKeys.Send("{RIGHT}");
return true;
}
else if (this.dataGridView2.CurrentCell.ColumnIndex == 2)
{
SendKeys.Send("{Down}");
SendKeys.Send("{LEFT}");
SendKeys.Send("{LEFT}");
return true;
}
}
}
//继续原来base.ProcessCmdKey中的处理
return base.ProcessCmdKey(ref msg, keyData);
}