private void SortInternal() { _bindingSource.Sort = $"{SortColumnName} {SortColumnOrder.ToDirectionString()}"; if (_slotList is IBindingList bindingList) { bindingList.ApplySort(bindingList.SortProperty, bindingList.SortDirection); } }
private void ResetBindingsInternal() { var control = _syncObject as Control; if (control != null && control.IsDisposed) { return; } if (_syncObject.InvokeRequired) { _syncObject.Invoke(new MethodInvoker(ResetBindingsInternal), null); return; } OnBeforeResetBindings(EventArgs.Empty); lock (_slotsListLock) { // halt binding source updates _bindingSource.RaiseListChangedEvents = false; // see Revision 534 commit comments for the reason // _slotList.RaiseListChangedEvents = false is here. _slotList.RaiseListChangedEvents = false; // get slots from the dictionary var slots = _clientConfiguration.Slots as IList <SlotModel> ?? _clientConfiguration.Slots.ToList(); // refresh the underlying binding list _bindingSource.Clear(); foreach (var slot in slots) { _bindingSource.Add(slot); } Debug.WriteLine("Number of slots: {0}", _bindingSource.Count); // sort the list _bindingSource.Sort = null; _bindingSource.Sort = SortColumnName + " " + SortColumnOrder.ToDirectionString(); // reset selected slot ResetSelectedSlot(); // find duplicates slots.FindDuplicates(); // enable binding source updates _bindingSource.RaiseListChangedEvents = true; // see Revision 534 commit comments for the reason // _slotList.RaiseListChangedEvents = false is here. _slotList.RaiseListChangedEvents = true; // reset AFTER RaiseListChangedEvents is enabled _bindingSource.ResetBindings(false); } OnAfterResetBindings(EventArgs.Empty); }
/// <summary> /// Sort the grid model /// </summary> public void Sort() { lock (_slotsListLock) { _bindingSource.RaiseListChangedEvents = false; // see Revision 534 commit comments for the reason // _slotList.RaiseListChangedEvents = false is here. _slotList.RaiseListChangedEvents = false; // sort the list _bindingSource.Sort = null; _bindingSource.Sort = SortColumnName + " " + SortColumnOrder.ToDirectionString(); // enable binding source updates _bindingSource.RaiseListChangedEvents = true; // see Revision 534 commit comments for the reason // _slotList.RaiseListChangedEvents = false is here. _slotList.RaiseListChangedEvents = true; } }