private void BreakRow(TableBase breakTo, int rowIndex, float rowHeight, float newRowHeight) { // set rows height TableRow rowTo = breakTo.Rows[rowIndex]; Rows[rowIndex].Height = rowHeight; rowTo.Height = newRowHeight; // break each cell in the row for (int i = 0; i < ColumnCount; i++) { TableCell cell = this[i, rowIndex]; TableCell cellTo = breakTo[i, rowIndex]; cell.Height = rowHeight; cell.Break(cellTo); // fix height if row is not autosized if (!rowTo.AutoSize) { float h = cellTo.CalcHeight(); if (h > rowTo.Height) { rowTo.Height = h; } } } }
/// <summary> /// Calculates height of the table cell. /// </summary> /// <param name="width">The width of the table cell.</param> /// <returns>The value of the table cell height.</returns> public float CalcHeight(float width) { TableCell cell = Cell; cell.SetReport(Table.Report); cell.Width = width; float cellHeight = cell.CalcHeight(); if (objects != null) { // pasted from BandBase.cs // sort objects by Top ReportComponentCollection sortedObjects = objects.SortByTop(); // calc height of each object float[] heights = new float[sortedObjects.Count]; for (int i = 0; i < sortedObjects.Count; i++) { ReportComponentBase obj = sortedObjects[i]; float height = obj.Height; if (obj.CanGrow || obj.CanShrink) { float height1 = obj.CalcHeight(); if ((obj.CanGrow && height1 > height) || (obj.CanShrink && height1 < height)) { height = height1; } } heights[i] = height; } // calc shift amounts float[] shifts = new float[sortedObjects.Count]; for (int i = 0; i < sortedObjects.Count; i++) { ReportComponentBase parent = sortedObjects[i]; float shift = heights[i] - parent.Height; if (shift == 0) { continue; } for (int j = i + 1; j < sortedObjects.Count; j++) { ReportComponentBase child = sortedObjects[j]; if (child.ShiftMode == ShiftMode.Never) { continue; } if (child.Top >= parent.Bottom - 1e-4) { if (child.ShiftMode == ShiftMode.WhenOverlapped && (child.Left > parent.Right - 1e-4 || parent.Left > child.Right - 1e-4)) { continue; } float parentShift = shifts[i]; float childShift = shifts[j]; if (shift > 0) { childShift = Math.Max(shift + parentShift, childShift); } else { childShift = Math.Min(shift + parentShift, childShift); } shifts[j] = childShift; } } } // update location and size of each component, calc max height float maxHeight = 0; for (int i = 0; i < sortedObjects.Count; i++) { ReportComponentBase obj = sortedObjects[i]; obj.Height = heights[i]; obj.Top += shifts[i]; if (obj.Bottom > maxHeight) { maxHeight = obj.Bottom; } } if (cellHeight < maxHeight) { cellHeight = maxHeight; } // perform grow to bottom foreach (ReportComponentBase obj in objects) { if (obj.GrowToBottom) { obj.Height = cellHeight - obj.Top; } } // ----------------------- } return(cellHeight); }