Reputation: 1
How to capture the enter key
in DataGridView.CellContentClick in c#
Upvotes: 0
Views: 2748
Reputation: 21864
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)
}
}
Upvotes: 1