Opening Dialog when user presses Enter key in List View

  • Thread starter Thread starter schnandr
  • Start date Start date
S

schnandr

Hi I am trying to open a Form when the user hits the Enter key in a
list view.

private void listView_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
OnEnterKey();
}
}

I registered a KeyUp handler. When I open the Form and I press the
Enter key in the dialog the dialog closes and the KeyUp event will be
fired again from the list view and the dialog will open again. Why
will this event will be fired when I press Enter in the dialog?

Thanks for every hint.
 
schnandr said:
Hi I am trying to open a Form when the user hits the Enter key in a
list view.

private void listView_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
OnEnterKey();
}
}

I registered a KeyUp handler. When I open the Form and I press the
Enter key in the dialog the dialog closes and the KeyUp event will
be fired again from the list view and the dialog will open again.
Why will this event will be fired when I press Enter in the dialog?

Thanks for every hint.

After you pressed the enter key down in the 2nd form, don't you release it?
;-) When you release it, the calling Form is active and receives the keyup
event. I'd catch KeyDown in the listview instead.


Armin
 
Back
Top