Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

When the user presses the Shift + UP keys, I want my form to respond by calling up a message box.

How do I do this in Windows Forms?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
340 views
Welcome To Ask or Share your Answers For Others

1 Answer

Handle the KeyDown event and have something like:

if (e.Modifiers == Keys.Shift && e.KeyCode == Keys.Up)
{
    MessageBox.Show("My message");
}

The event handler has to be on the Main Form and you need to set the KeyPreview property to true. This can be done in design mode from the properties dialog.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...