如何在DataGridView CellContentClick中捕获回车键

时间:2011-05-08 09:42:37

标签: c# winforms keyevent

如何在c#中捕获DataGridView.CellContentClick中的enter key

1 个答案:

答案 0 :(得分:1)

只处理spacebar,因此您必须首先捕获单元格上的KeyUp event,如果需要,请提升CellContentClick

private void cell_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
    if(e.KeyCode == Keys.Enter)
    {
        // modify/cast/transform e here to DataGridViewCellEventArgs
        dataGridView_CellContentClick(sender, e) 
    }
}