Measure() public method

If the cell is not linked to a grid the result is not accurate (Font can be null). Call InternalGetRequiredSize with RowSpan and ColSpan = 1.
public Measure ( System maxLayoutArea ) : System.Drawing.Size
maxLayoutArea System SizeF structure that specifies the maximum layout area for the text. If width or height are zero the value is set to a default maximum value.
return System.Drawing.Size
Exemplo n.º 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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Measures the current column when drawn with the specified cells.
        /// </summary>
        /// <param name="column"></param>
        /// <param name="useRowHeight">True to fix the row height when measure the column width.</param>
        /// <param name="StartRow">Start row to measure</param>
        /// <param name="EndRow">End row to measure</param>
        /// <returns>Returns the required width</returns>
        public int MeasureColumnWidth(int column, bool useRowHeight, int StartRow, int EndRow)
        {
            int min = Grid.MinimumWidth;

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

            for (int r = StartRow; r <= EndRow; r++)
            {
                Cells.ICellVirtual cell = Grid.GetCell(r, column);
                if (cell != null)
                {
                    Position cellPosition = new Position(r, column);

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

                    CellContext cellContext = new CellContext(Grid, cellPosition, cell);
                    Size        cellSize    = cellContext.Measure(maxLayout);
                    if (cellSize.Width > min)
                    {
                        min = cellSize.Width;
                    }
                }
            }
            return(min);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Measures the current column when drawn with the specified cells.
        /// </summary>
        /// <param name="column"></param>
        /// <param name="useRowHeight">True to fix the row height when measure the column width.</param>
        /// <param name="StartRow">Start row to measure</param>
        /// <param name="EndRow">End row to measure</param>
        /// <returns>Returns the required width</returns>
        public int MeasureColumnWidth(int column, bool useRowHeight, int StartRow, int EndRow)
        {
            int min = Grid.MinimumWidth;

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

            for (int r = StartRow; r <= EndRow; r++)
            {
                Cells.ICellVirtual cell = Grid.GetCell(r, column);
                if (cell != null)
                {
                    Size maxLayout = Size.Empty;
                    if (useRowHeight)
                    {
                        maxLayout.Height = Grid.Rows.GetHeight(r);
                    }

                    CellContext cellContext = new CellContext(Grid, new Position(r, column), cell);

                    Size l_size = cellContext.Measure(maxLayout);
                    if (l_size.Width > min)
                    {
                        min = l_size.Width;
                    }
                }
            }
            return(min);
        }
Exemplo n.º 4
0
		/// <summary>
		/// Measures the current column when drawn with the specified cells.
		/// </summary>
		/// <param name="column"></param>
		/// <param name="useRowHeight">True to fix the row height when measure the column width.</param>
		/// <param name="StartRow">Start row to measure</param>
		/// <param name="EndRow">End row to measure</param>
		/// <returns>Returns the required width</returns>
		public int MeasureColumnWidth(int column, bool useRowHeight, int StartRow, int EndRow)
		{
			int min = Grid.MinimumWidth;
			
			if ((GetAutoSizeMode(column) & AutoSizeMode.MinimumSize) == AutoSizeMode.MinimumSize)
				return min;
			
			for (int r = StartRow; r <= EndRow; r++)
			{
				Cells.ICellVirtual cell = Grid.GetCell(r, column);
				if (cell != null)
				{
					Position cellPosition = new Position(r, column);
					
					Size maxLayout = Size.Empty;
					//Use the width of the actual cell (considering spanned cells)
					if (useRowHeight)
						maxLayout.Height = Grid.RangeToSize(Grid.PositionToCellRange(cellPosition)).Height;
					
					CellContext cellContext = new CellContext(Grid, cellPosition, cell);
					Size cellSize = cellContext.Measure(maxLayout);
					if (cellSize.Width > min)
						min = cellSize.Width;
				}
			}
			return min;
		}
Exemplo n.º 5
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;
		}