KeyUp in response to MessageBox ends up in main form

  • Thread starter Thread starter Houston Keach
  • Start date Start date
H

Houston Keach

I am dispalying a message box from my main form with the following
code:

DialogResult response = MessageBox.Show( "Delete Location ?",
"Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button2 );

If the user enters a "Y" or "N" from the keyboard, I am getting a
KeyUp event for the pressed key in the focused TextBox in my main
form. I do not, however, get a KeyPress event. This can't be right,
can it? I'm taking a variety of actions on the KeyUp event and I
can't figure a way to work around this bogus character.

--Houston
 
Did you ever get a reply to this post? Or, did you ever
come up with a solution. I have been banging my head
against the wall for weeks trying to figure this one out.
In my case some one is pressing the Enter key in the
message box and the Enter key is being passed to the
keyup routine for the active form.
 
I may have come up with something... If I use the KeyDown
method instead of the KeyUp method my routines work
correctly. My guess would be that MessageBox uses a
KeyDown method. If this is so then a KeyUp event is still
waiting out there to be processed. My guess is that is
why our objects that have focus are responding to the
KeyUp from the MessageBox.

Hope this helps your situation.

Nathan
 
Back
Top