//绑定数据源的Focuse Row 发生改变时产生 void _BindingSource_PositionChanged(object sender, EventArgs e) { if (MB.Util.General.IsInDesignMode()) { return; } if (_CurrentIsCancelAddNew) { return; } if (!_EditBindingSource.CheckExistsCurrentItem()) { return; } _DataValidated.ClearErrorMessage(_EditColumnCtlBinding); OnBindingSourcePositionChanged(); System.ComponentModel.INotifyPropertyChanged currentMainEditEntity = _EditBindingSource.Current as System.ComponentModel.INotifyPropertyChanged; if (currentMainEditEntity != null) { foreach (INotifyPropertyChanged item in _HasAddMainEntityEvent) { item.PropertyChanged -= new PropertyChangedEventHandler(OnCurrentMainEditEntity_PropertyChanged); } _HasAddMainEntityEvent.Clear(); _HasAddMainEntityEvent.Add(currentMainEditEntity); currentMainEditEntity.PropertyChanged += new PropertyChangedEventHandler(OnCurrentMainEditEntity_PropertyChanged); } }
internal CollectionViewProxy(ICollectionView view) { this.view = view; view.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnCollectionChanged); view.CurrentChanging += new SCM.CurrentChangingEventHandler(this.OnCurrentChanging); view.CurrentChanged += new EventHandler(this.OnCurrentChanged); SCM.INotifyPropertyChanged notifyPropertyChanged = view as SCM.INotifyPropertyChanged; if (notifyPropertyChanged != null) { notifyPropertyChanged.PropertyChanged += new SCM.PropertyChangedEventHandler(this.OnPropertyChanged); } }
private void OnDeserializedHandler(StreamingContext context) { OnDeserialized(context); foreach (Core.IEditableBusinessObject child in this) { child.SetParent(this); System.ComponentModel.INotifyPropertyChanged c = child as System.ComponentModel.INotifyPropertyChanged; if (c != null) { c.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Child_PropertyChanged); } } }
//绑定数据源的Focuse Row 发生改变时产生 void _BindingSource_PositionChanged(object sender, EventArgs e) { if (MB.Util.General.IsInDesignMode()) { return; } if (_CurrentIsCancelAddNew) { return; } if (!_BindingSource.CheckExistsCurrentItem()) { return; } _DataValidated.ClearErrorMessage(_EditColumnCtlBinding); OnBindingSourcePositionChanged(); System.ComponentModel.INotifyPropertyChanged currentMainEditEntity = _BindingSource.Current as System.ComponentModel.INotifyPropertyChanged; if (currentMainEditEntity != null) { foreach (INotifyPropertyChanged item in _HasAddMainEntityEvent) { item.PropertyChanged -= new PropertyChangedEventHandler(OnCurrentMainEditEntity_PropertyChanged); } _HasAddMainEntityEvent.Clear(); _HasAddMainEntityEvent.Add(currentMainEditEntity); currentMainEditEntity.PropertyChanged += new PropertyChangedEventHandler(OnCurrentMainEditEntity_PropertyChanged); } //如果在新增的状态下,需要附上默认值,默认值赋值结束以后,关闭_IsInAdding开关 if (_IsInAdding) { try { PopulateDefaultValue(currentMainEditEntity, _ClientRuleObject); } finally { //重置_IsInAdding为false; _IsInAdding = false; } } }
/// <summary> /// Removes an item from the list. /// </summary> /// <param name="index">Index of the item /// to be removed.</param> protected override void RemoveItem(int index) { // delete item from database T item = this[index]; // only delete/save the item if it is not new if (!item.IsNew) { item.Delete(); SaveItem(index); } // disconnect event handler if necessary System.ComponentModel.INotifyPropertyChanged c = item as System.ComponentModel.INotifyPropertyChanged; if (c != null) { c.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(Child_PropertyChanged); } base.RemoveItem(index); }