KeyUp in response to MessageBox ends up in main form

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
 
N

Nathan Kerr

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.
 
N

Nathan Kerr

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
 

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