[Tips][NumericUpDown] [PageDown][PageUp]キーで値を変化させる




Private Sub NumericUpDown1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles NumericUpDown1.KeyDown
    If e.KeyCode = Keys.PageDown And
        NumericUpDown1.Value >= NumericUpDown1.Minimum + STEP_VALUE Then    '[PageDown]押下時

        NumericUpDown1.Value -= STEP_VALUE

    ElseIf e.KeyCode = Keys.PageUp And
        NumericUpDown1.Value <= NumericUpDown1.Maximum - STEP_VALUE Then    '[PageUp]押下時

        NumericUpDown1.Value += STEP_VALUE
    End If
End Sub


private void NumericUpDown1_KeyDown(object sender, KeyEventArgs e)
    if (e.KeyCode == Keys.PageDown &&
        numericUpDown1.Value >= numericUpDown1.Minimum + STEP_VALUE)	//[PageDown]押下時

        numericUpDown1.Value -= STEP_VALUE;

    else if (e.KeyCode == Keys.PageUp &&
        numericUpDown1.Value <= numericUpDown1.Maximum - STEP_VALUE)	//[PageUp]押下時

        numericUpDown1.Value += STEP_VALUE;


メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

This site uses Akismet to reduce spam. Learn how your comment data is processed.