给定一个变量int i;  当i值改变时触发事件 求思路求框架

解决方案 »

  1.   

    deleate void ichange(int i);public event ichange  _change;
    int ic=0;
    if(i!=ic)
    {
      if(_change!=null)
    {
      _change(i);
    }
    }
      

  2.   

    deleate void IChangeHander(Object sender, IChangeAgrs e);
    public class IChangeArgs
    {
        public int oldValue{get;set;}
        public int newValue{get;set;}
    }
    public event IChangeHander _IChangeHander;int _i;
    public int i
    {
        get { return _i;}
        set
        {
            IChangeAgrs e = new IChangeAgrs(){oldValue=_i,newValue=value};
            _i=value;
            _IChangeHander(this, e);
        }
    }
      

  3.   

    public class Person : INotifyPropertyChanged
    {
      private string firstNameValue;
      public string FirstName{
      get { return firstNameValue; }
      set
      {
      firstNameValue=value;
      NotifyPropertyChanged("FirstName");
      }
      }
      public event PropertyChangedEventHandler PropertyChanged;
      public void NotifyPropertyChanged(string propertyName)
      {
      if (PropertyChanged != null)
      {
      PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
      }
      }   
    }
      

  4.   

    在winform中,变量存放在一个类中,通过改变这个类中的变量来实时触发winform中的程序呢?
    其实我是想通过这样来改变窗体大小的。通过改变类中的变量来实时改变winform的高度宽度