在datagrid的keyUp事件中添加代码 private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e) { char a = (char)Keys.Enter; if (e.KeyChar == a) { int i = dataGridView1.CurrentCell.ColumnIndex; if (i < dataGridView1.Columns.Count -1) { dataGridView1.CurrentCell = dataGridView1.CurrentRow.Cells[i + 1]; } } }
{
char a = (char)Keys.Enter;
if (e.KeyChar == a)
{
int i = dataGridView1.CurrentCell.ColumnIndex;
if (i < dataGridView1.Columns.Count -1)
{
dataGridView1.CurrentCell = dataGridView1.CurrentRow.Cells[i + 1];
}
}
}
e.parentNode.nextSibling.focus();
e代表当前单元格中的一个控件
{
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Enter)
{
System.Windows.Forms.SendKeys.Send("{tab}");
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
直接使用 MyData来做把.