现在在一个form中有很多NumericUpDown和一个按钮,想实现这样一种功能,按钮的Enable属性开始为false(在构造函数中设置),如果有任意一个NumericUpDown的值发生变化,则按钮的Enable属性变成ture。我现在采用的方法是双击每个NumericUpDown,会产生一个
private void mNumeric_ValueChanged(object sender, System.EventArgs e)函数,在其中添加改变按钮属性的的语句即可。但是这样太麻烦了,而且我也怀疑会影响到程序的时效性。恳求更简洁,更高效的编程方法。

解决方案 »

  1.   

    多个NumericUpDown可以用同个事件吧
      

  2.   

    右键点NumericUpDown控件 选属性 在事件那可以用下拉框选择已有的可用事件
      

  3.   

    先双击每个NumericUpDown产生一个 
    private void mNumeric_ValueChanged(object sender, System.EventArgs e)函数
    然后将 
    private void mNumeric_ValueChanged(object sender, System.EventArgs e)函数删除到剩一个
    接着到Form.Designer.cs中去把所有的NumericUpDown的ValueChanged事件都订阅到剩下的那个事件处理函数去
    this.NumericUpDown.ValueChanged+= new System.EventHandler(this.mNumeric_ValueChanged);
      

  4.   


    三个NumericUpDown 注册一个事件里去
    this.NumericUpDown1.ValueChanged+= new System.EventHandler(this.mNumeric_ValueChanged);
    this.NumericUpDown2.ValueChanged+= new System.EventHandler(this.mNumeric_ValueChanged);
    this.NumericUpDown3.ValueChanged+= new System.EventHandler(this.mNumeric_ValueChanged);
      

  5.   

    将三个NumericUpDown的ValueChanged事件的函数选成一个就可以少些很多了