コード例 #1
0
        private void OnSourceListItemChanged(ListChangedEventArgs e)
        {
            //Console.WriteLine("OnSourceListItemChanged: {0} {1}", e.NewIndex, ((DataRowView)SourceList[e.NewIndex])[0]);

            int  rowIndex                 = e.NewIndex + 1;
            bool rowVisible               = IsRowVisible(rowIndex);
            bool anyCellVisible           = false;
            ChangedFieldInfoCollection cc = GetChangedFields();

            if (cc.Count > 0)
            {
                foreach (ChangedFieldInfo fi in cc)
                {
                    int columnIndex = fi.FieldIndex + 1;

                    PropertyDescriptor pd = _pdc[columnIndex - 1];
                    if (pd.PropertyType == typeof(double))
                    {
                        _totals[columnIndex - 1] += fi.Delta;
                        if (!_invalidateWholeSummaryRow)
                        {
                            InvalidateCell(new RowColumnIndex(SourceList.Count + 1, columnIndex));
                        }
                    }

                    RowColumnIndex cellRowColumnIndex = new RowColumnIndex(rowIndex, columnIndex);
                    if (CurrentCell.CellRowColumnIndex == cellRowColumnIndex)
                    {
                        if (!CurrentCell.IsInConfirmChanges)
                        {
                            CurrentCell.RejectChanges();
                            Model.VolatileCellStyles.Clear(cellRowColumnIndex);
                            RenderStyles.Clear(cellRowColumnIndex);
                            CurrentCell.Renderer.RefreshContent();
                        }
                        else
                        {
                            this.InvalidateCell(cellRowColumnIndex);
                            continue;
                        }
                    }
                    else
                    {
                        InvalidateCell(cellRowColumnIndex);
                    }
                    if (rowVisible)
                    {
                        anyCellVisible |= IsColumnVisible(columnIndex);
                    }
                }
                if (_invalidateWholeSummaryRow)
                {
                    InvalidateCell(GridRangeInfo.Row(SourceList.Count + 1));
                }
            }
            else
            {
                for (int n = 0; n < _pdc.Count; n++)
                {
                    int            columnIndex = n + 1;
                    RowColumnIndex cell        = new RowColumnIndex(rowIndex, columnIndex);
                    if (rowVisible)
                    {
                        anyCellVisible |= IsColumnVisible(columnIndex);
                    }
                }
            }
            Blink(e);
            ProcessBlinkQueue();
            if (anyCellVisible)
            {
                InvalidateVisual(false);
            }
        }