Datagridview and the Enter Key

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

Hi all,

I have a datagrid that doesnt allow the user to edit. When the user
clicks a row, the whole row gets selected.

I'd like it so that when the user has a row selected and presses enter,
a new form is opened and passed data from the row.

At the moment, when I press enter, I can get the window to open, but the
selected row moves down one. Is there any way I can surpress this
behavior when pressing enter?

Many thanks

Simon
 
Try handling the DataGridView.KeyDown event and settinge.handler =
true if it is the Enter key.

void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
e.Handled = true;
}
}

===================
Clay Burch
Syncfusion, Inc.
 
Back
Top