Reputation: 14787
I have a NumericUpDown control in WinForms. The Up/Down arrow keys increase/decrease the value by 1. I want to map the PageUp/PageDown keys for larger increments.
The Control.KeyPress
event does not get fired with the PageUp/PageDown keys and if I use the Control.KeyUp/Control.KeyDown
events, the combination fires only once even if the user keeps the keys pressed for a while.
How could I trap multiple PageUp/PageDown keys presses during long key presses?
Upvotes: 1
Views: 558
Reputation: 405
Strange to say, but I cannot reproduce this issue. I have a new winform instance, numericUpDown control with default property` values and KeyDown event handler works perfectly with long key press:
private void numericUpDown1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.PageDown)
numericUpDown1.Value -= 10;
else if (e.KeyCode == Keys.PageUp)
numericUpDown1.Value += 10;
}
Can you provide your code in the event handlers? /Sorry, I know Im not supposed to ask for clarification in the answer, but I can`t write comments./
Upvotes: 1