SourceGrid.Grid.PositionToCellRange C# (CSharp) Method

PositionToCellRange() public method

This method converts a Position to the real range of the cell. This is usefull when RowSpan or ColumnSpan is greater than 1. For example suppose to have at grid[0,0] a cell with ColumnSpan equal to 2. If you call this method with the position 0,0 returns 0,0-0,1 and if you call this method with 0,1 return again 0,0-0,1.
public PositionToCellRange ( Position pPosition ) : Range
pPosition Position
return Range
        public override Range PositionToCellRange(Position pPosition)
        {
            if (pPosition.IsEmpty())
                return Range.Empty;

            Cells.ICell l_Cell = this[pPosition.Row, pPosition.Column];
            if (l_Cell == null)
                return new Range(pPosition);
            else
                return l_Cell.Range;
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// Measures the current row when drawn with the specified cells.
        /// </summary>
        /// <param name="row"></param>
        /// <param name="useColumnWidth">True to fix the column width when calculating the required height of the row.</param>
        /// <param name="StartCol">Start column to measure</param>
        /// <param name="EndCol">End column to measure</param>
        /// <returns>Returns the required height</returns>
        public int MeasureRowHeight(int row, bool useColumnWidth, int StartCol, int EndCol)
        {
            int min = Grid.MinimumHeight;

            if ((GetAutoSizeMode(row) & AutoSizeMode.MinimumSize) == AutoSizeMode.MinimumSize)
            {
                return(min);
            }

            for (int c = StartCol; c <= EndCol; c++)
            {
                Cells.ICellVirtual cell = Grid.GetCell(row, c);
                if (cell != null)
                {
                    Position cellPosition = new Position(row, c);

                    Size maxLayout = Size.Empty;
                    //Use the width of the actual cell (considering spanned cells)
                    if (useColumnWidth)
                    {
                        maxLayout.Width = Grid.RangeToSize(Grid.PositionToCellRange(cellPosition)).Width;
                    }

                    CellContext cellContext = new CellContext(Grid, cellPosition, cell);
                    Size        cellSize    = cellContext.Measure(maxLayout);
                    if (cellSize.Height > min)
                    {
                        min = cellSize.Height;
                    }
                }
            }
            return(min);
        }
All Usage Examples Of SourceGrid.Grid::PositionToCellRange