public override void CreateNullSelectable(BaseBindingList <TItemType> selectable) { var newItem = new TItemType { Name = "" }; newItem.ClearWarnings(); selectable.Add(newItem); }
public void UpdateSelectable(BaseBindingList <TChildType> bindingList, BaseBindingList <TChildType> selectable) { var nbOldSelectable = selectable.Count; var nbNewSelectable = bindingList.Count + ((NullSelectable) ? 1 : 0); for (var i = 1; i < nbNewSelectable; ++i) { if (i < nbOldSelectable) { selectable[i] = bindingList[i - ((NullSelectable) ? 1 : 0)]; } else { selectable.Add(bindingList[i - ((NullSelectable) ? 1 : 0)]); } } for (var i = nbNewSelectable; i < nbOldSelectable; ++i) { selectable.RemoveAt(nbNewSelectable); } selectable.ResetBindings(); }
public void Read(BaseBindingList <TChildType> bindingList, BaseBindingList <TChildType> selectable, TChildType[] array, object parent) { if (Sorted) { array = array.OrderBy(KeySelector).ToArray(); } var lastRaiseListChangedEvents = bindingList.RaiseListChangedEvents; bindingList.RaiseListChangedEvents = false; selectable.RaiseListChangedEvents = false; bindingList.Clear(); foreach (var item in array) { item.Parent = parent; bindingList.Add(item); } if (Selectable) { UpdateSelectable(bindingList, selectable); } bindingList.RaiseListChangedEvents = lastRaiseListChangedEvents; selectable.RaiseListChangedEvents = lastRaiseListChangedEvents; }