Exemplo n.º 1
0
        public void UpdateResults()
        {
            if (null == _queryRequestor)
            {
                return;
            }
            if (ReferenceEquals(_queryRequestor.QueryResults, QueryResults))
            {
                return;
            }
            var queryResults = _queryRequestor.QueryResults;

            if (queryResults == null)
            {
                return;
            }
            _queryResults = queryResults;
            bool rowCountChanged = Count != QueryResults.ResultRows.Count;
            var  newRow          = _newRow;

            if (newRow != null)
            {
                int newRowPos = Items.IndexOf(newRow);
                CancelNew(newRowPos);
            }
            RowItemList.Clear();
            RowItemList.AddRange(QueryResults.ResultRows);
            if (newRow != null && !NewRowHandler.IsNewRowEmpty(newRow))
            {
                _newRow = newRow;
                AddNew();
            }

            bool propsChanged = !ItemProperties.SequenceEqual(QueryResults.ItemProperties);

            _reportResults = QueryResults.TransformResults.PivotedRows;
            AllowNew       = NewRowHandler != null;
            AllowEdit      = true;
            AllowRemove    = false;
            if (propsChanged)
            {
                OnListChanged(new ListChangedEventArgs(ListChangedType.PropertyDescriptorChanged, 0));
                ResetBindings();
            }
            else if (rowCountChanged || 0 == Count)
            {
                ResetBindings();
            }
            else
            {
                OnAllRowsChanged();
            }
        }