Datagridview and the Enter Key

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
 
C

ClayB

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top