SourceGrid.Range.MoveTo C# (CSharp) Method

MoveTo() public method

Move the current range to the specified position, leaving the current ColumnsCount and RowsCount
public MoveTo ( Position p_StartPosition ) : void
p_StartPosition Position
return void
        public void MoveTo(Position p_StartPosition)
        {
            int l_ColCount = ColumnsCount;
            int l_RowCount = RowsCount;
            m_Start = p_StartPosition;
            RowsCount = l_RowCount;
            ColumnsCount = l_ColCount;
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// Write the current loaded array string in the specified grid range. This method use the cell editor to set the value.
        /// </summary>
        /// <param name="destinationGrid"></param>
        /// <param name="destinationRange"></param>
        public void WriteData(GridVirtual destinationGrid, Range destinationRange)
        {
            //Calculate the destination Range merging the source range
            Range newRange = mSourceRange;

            newRange.MoveTo(destinationRange.Start);
            if (newRange.ColumnsCount > destinationRange.ColumnsCount)
            {
                newRange.ColumnsCount = destinationRange.ColumnsCount;
            }
            if (newRange.RowsCount > destinationRange.RowsCount)
            {
                newRange.RowsCount = destinationRange.RowsCount;
            }

            //Cut Data
            if (CutMode == CutMode.CutOnPaste && mSourceGrid != null)
            {
                for (int sr = mSourceRange.Start.Row; sr <= mSourceRange.End.Row; sr++)
                {
                    for (int sc = mSourceRange.Start.Column; sc <= mSourceRange.End.Column; sc++)
                    {
                        Position           pos         = new Position(sr, sc);
                        Cells.ICellVirtual cell        = mSourceGrid.GetCell(sr, sc);
                        CellContext        cellContext = new CellContext(mSourceGrid, pos, cell);
                        if (cell.Editor != null)
                        {
                            cell.Editor.ClearCell(cellContext);
                        }
                    }
                }
            }

            int arrayRow = 0;

            for (int r = newRange.Start.Row; r <= newRange.End.Row; r++, arrayRow++)
            {
                int arrayCol = 0;
                for (int c = newRange.Start.Column; c <= newRange.End.Column; c++, arrayCol++)
                {
                    Position           posCell     = new Position(r, c);
                    Cells.ICellVirtual cell        = destinationGrid.GetCell(posCell);
                    CellContext        cellContext = new CellContext(destinationGrid, posCell, cell);

                    if (cell != null && cell.Editor != null && mSourceValues[arrayRow, arrayCol] != null)
                    {
                        cell.Editor.SetCellValue(cellContext, mSourceValues[arrayRow, arrayCol]);
                    }
                }
            }
        }
All Usage Examples Of SourceGrid.Range::MoveTo