c# - 在 C# 中是否存在值增加的 numericupdown 事件

标签 c# events numericupdown eventhandler

我需要一个在按下向上箭头时发生的事件和另一个在按下向下箭头时发生的事件。有这个事件处理程序吗?我能找到的只是 valuechanged 吗?

最佳答案

简短的回答是,没有这样的事件。 但是,很容易检查它是增加还是减少值(value)。例如,如果您将 numericupdown 的值绑定(bind)到 View 模型中的一个属性,您可以这样做:

private int upDownValue;

public int UpDownValue
{
    get{ return this.upDownValue; }
    set
    {
        if(value > this.upDownValue)
        {
             //It increased
        }

        if(value < this.upDownValue)
        {
            //It decreased
        }

        this.upDownValue = value;
    }
}

关于c# - 在 C# 中是否存在值增加的 numericupdown 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28473808/

相关文章:

C#:我可以像在 C++ 中那样写 "private:"或 "protected:"区域吗

c# - 异步等待或只是 TasK<T>

javascript - 添加/删除事件监听器

c# - 如何使用一种方法禁用多个 NumericUpDown 控件?

C# 随 secret 码生成器

c# - 将数据推送到 ko.observableArray

c# - 在 Automapper 中映射时忽略导航属性

c# - 取消订阅事件

events - 退订页面更改事件

c# - 获取 NumericUpDown 的值会移动插入符位置,我可以停止吗?