简体   繁体   中英

How to capture enter key in DataGridView CellContentClick

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

only the spacebar is handled, so you have to capture the KeyUp event on the cell first and raise the CellContentClick if you want that .

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) 
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM