Пример #1
0
        /// <summary>
        /// Get covered cell info through event.
        /// </summary>
        /// <param name="rowIndex"></param>
        /// <param name="columnIndex"></param>
        /// <param name="gridColumn"></param>
        /// <param name="record"></param>
        /// <returns></returns>
        internal CoveredCellInfo GetCoveredCell(int rowIndex, int columnIndex, GridColumn gridColumn, object record)
        {
            if ((dataGrid.SelectionMode != GridSelectionMode.Single && dataGrid.SelectionMode != GridSelectionMode.None) || dataGrid.SelectionUnit == GridSelectionUnit.Row || dataGrid.SelectionUnit == GridSelectionUnit.Any || dataGrid.NavigationMode == NavigationMode.Row || dataGrid.AllowFrozenGroupHeaders)
            {
                throw new NotSupportedException(string.Format("Merged Cell will not support with {0}, {1}, {2}, AllowFrozenGroupedHeaders {3}", dataGrid.SelectionMode, dataGrid.SelectionUnit, dataGrid.NavigationMode, dataGrid.AllowFrozenGroupHeaders));
            }

            CoveredCellInfo range = null;

            if (dataGrid.GridModel == null)
            {
                return(range);
            }

            GetCoveredCellInfo(out range, rowIndex, columnIndex);


            if (range != null)
            {
                return(range);
            }

            GridQueryCoveredRangeEventArgs e = new GridQueryCoveredRangeEventArgs(new RowColumnIndex(rowIndex, columnIndex), gridColumn, record, dataGrid);

            dataGrid.RaiseQueryCoveredRange(e);
            range = e.Range;

            if (range != null && e.Handled)
            {
                if (range.Contains(rowIndex, columnIndex))
                {
                    if (IsInRange(range))
                    {
                        throw new Exception(String.Format("Conflict detected when trying to save {0}", range));
                    }
                    range.MappedRowColumnIndex = new RowColumnIndex(range.Top, columnIndex);
                    this.dataGrid.coveredCells.Add(range);
                    return(range);
                }
            }
            return(null);
        }