public void RebindGroups() { BeginUpdate(); HashSet <object> setGroups = _sourceGroups != null ? new HashSet <object>(_sourceGroups) : new HashSet <object>(); BetterListViewGroup[] toDelete = Groups. Where(g => !setGroups.Contains(g.DataObject())). ToArray(); foreach (BetterListViewGroup group in toDelete) { Groups.Remove(group); } BetterListViewGroup[] toUpdate = Groups. Where(g => setGroups.Contains(g.DataObject())). ToArray(); foreach (BetterListViewGroup group in toUpdate) { group.Refresh(); } IEnumerable <object> toAdd = setGroups.Except(Groups.Select(g => g.DataObject())); List <BetterListViewGroup> groupsToAdd = new List <BetterListViewGroup>(); foreach (object dataObject in toAdd) { TaskListViewSourceGroup source = new TaskListViewSourceGroup(dataObject, _funcGroupValueMember, _funcGroupDisplayMember); BetterListViewGroup group = new BetterListViewGroup(); group.BindDataSource(source); groupsToAdd.Add(group); } Groups.AddRange(groupsToAdd); EndUpdate(); }
public static void Refresh(this BetterListViewGroup group) { TaskListViewSourceGroup source = group.DataSource(); group.Header = source?.ToString(); }
public static void BindDataSource(this BetterListViewGroup group, TaskListViewSourceGroup source) { group.Tag = source; group.Refresh(); }