Answer the question
In order to leave comments, you need to log in
The OnKeyDown method does not work. Where is the mistake?
I need to handle the KeyDown event for the arrows. KeyDown is not processed when clicking on the arrows, so I specify which keys to respond to through IsInputKey and then work with this in OnKeyDown:
protected override bool IsInputKey(Keys keyData)
{
switch (keyData)
{
case Keys.Right:
case Keys.Left:
case Keys.Up:
case Keys.Down:
return true;
}
return base.IsInputKey(keyData);
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
MessageBox.Show("efg");
}
Answer the question
In order to leave comments, you need to log in
See how switch works. And make sure that this event comes to the method using a breakpoint.
Console.WriteLine("Нажмите Y или N");
string selection = Console.ReadLine();
switch (selection)
{
case "Y":
Console.WriteLine("Вы нажали букву Y");
break;
case "N":
Console.WriteLine("Вы нажали букву N");
break;
default:
Console.WriteLine("Вы нажали неизвестную букву");
break;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question