/// <summary> /// Handles a change to a SettlementUnit record in the data model. /// </summary> /// <param name="sender">The object that originated the event.</param> /// <param name="e">The event arguments.</param> private void OnSettlementUnitRowDeleted(Object sender, DataModel.SettlementUnitRowChangeEventArgs e) { // This will delete the item from the list when it is deleted from the data model. if (e.Action == DataRowAction.Delete) { Int32 index = this.BinarySearch(settlementUnitItem => settlementUnitItem.SettlementUnitCode, e.Row.SettlementUnitCode); if (index >= 0) { this.RemoveAt(index); } } }
/// <summary> /// Handles a change to a SettlementUnit record in the data model. /// </summary> /// <param name="sender">The object that originated the event.</param> /// <param name="e">The event arguments.</param> private void OnSettlementUnitRowChanged(Object sender, DataModel.SettlementUnitRowChangeEventArgs e) { // We're only interested in additions and changes in this handler. if (e.Action == DataRowAction.Add || e.Action == DataRowAction.Change) { // If the item doesn't exist, it is added. If it exists, it's updated. Int32 index = this.BinarySearch(settlementUnitItem => settlementUnitItem.SettlementUnitCode, e.Row.SettlementUnitCode); if (index < 0) { this.Insert(~index, new SettlementUnitItem(e.Row)); } else { this[index].Copy(e.Row); } } }