我需要能够使用Keyup事件激活numericupdown箭头。 [英] I need to be able to activate numericupdown arrows with a Keyup event.

查看:116
本文介绍了我需要能够使用Keyup事件激活numericupdown箭头。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要按键盘键才能激活向上箭头,我需要按另一个键来激活numericupdown类对象的向下箭头。






如何实施这种控制方案?

解决方案

你好,


您可以创建自己的方法,将方法添加到inc / dec值,如下所示。由于内部方法UpButton()和DownButton()遵循控件的最小值和最大值的规则,因此我们基本上与单击向上/向下箭头相同。

 public class CustomNumericUpDown:System.Windows.Forms.NumericUpDown 
{
public void IncrementValue()
{
UpButton();
}
public void DecrementValue()
{
DownButton();
}
}

VB.NET

 Public Class CustomNumericUpDown 
Inherits System.Windows.Forms.NumericUpDown
Public Sub IncrementValue()
UpButton()
End Sub
Public Sub DecrementValue()
DownButton()
结束子
结束类

调用增量

 customNumericUpDown1。 IncrementValue(); 

递减

 customNumericUpDown1.DecrementValue(); 


$





I need to be able to press a keyboard key to activate the Up arrow,and I need to press a different key to activate the down arrow of a numericupdown class object.



How would I implement this control scheme?

解决方案

Hello,

You could create your own, add methods to inc/dec values as shown below. Since the internal methods UpButton() and DownButton() adhere to the rules for min and max value of the control we are essentially doing the same as clicking up/down arrows.

    public class CustomNumericUpDown : System.Windows.Forms.NumericUpDown
    {
        public void IncrementValue()
        {
            UpButton();
        }
        public void DecrementValue()
        {
            DownButton();
        }
    }

VB.NET

Public Class CustomNumericUpDown
    Inherits System.Windows.Forms.NumericUpDown
    Public Sub IncrementValue()
        UpButton()
    End Sub
    Public Sub DecrementValue()
        DownButton()
    End Sub
End Class

Call the increment

customNumericUpDown1.IncrementValue();

Decrement

customNumericUpDown1.DecrementValue();


这篇关于我需要能够使用Keyup事件激活numericupdown箭头。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆