public void AddRange(IEnumerable <LostObject> lostObjects) { LostObjects.AddRange(lostObjects); // NOTE: adding items via wrapper's AddRange doesn't generate ListChanged event, so DataGridView doesn't update itself // There are two solutions: // 0. Add items one by one using direct this.Add method (without IList<T> wrapper). // Too many ListChanged events will be generated (one per item), too many updates for gridview. Bad performance. // 1. Batch add items through Items wrapper's AddRange method. // One reset event will be generated, one batch update for gridview. Ugly but fast code. OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1)); }
protected override void ApplySortCore(PropertyDescriptor propertyDescriptor, ListSortDirection direction) { LostObjects.Sort(LostObjectsComparer.Create(propertyDescriptor, direction == ListSortDirection.Descending)); }