Hi all,
I have a datagridview displaying some details in a List Form.On double clicking each row,an edit form is opened where we can edit the details of the selected record.
Now i have to implement Alt+E combination so that when user press Alt+E instead of doubleclicking a record of grid, he should get edit form for the selected record.Remember there is no button for edit.
Kindly help me as soon as possible.
Thanks in advance.
Simi JPosted Mar 16, 2008, 7:35 AM
AlanPosted Mar 10, 2008, 7:25 AM
You'll need to set the form's KeyPreview property to 'true' for that to work.
Otherwise keyboard events go directly to whichever control has the input focus at the time.
Simi JPosted Mar 10, 2008, 2:40 AM
Simi JPosted Mar 10, 2008, 1:25 AM
AlanPosted Mar 8, 2008, 8:33 AM
I'd try handling the DGV's KeyDown event and, if Alt+E is pressed, redirect to the DoubleClick event handler or otherwise reproduce the code needed to open up the edit form. Something like this:
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if(e.Alt && e.KeyCode == Keys.E)
{
// prevent any further processing
e.Handled = true;
//redirect to DoubleClick event handler, say
dataGridView1_DoubleClick(sender, new EventArgs());
}
}