I need to pass the value of a new cell. this is because I need to make the same logic as in ItextSharp, that logic being that I need to be able to create a table only by adding cells.
Instead of adding rows and then adding the cells to the rows.
var cellValue = new Cell();
((Row)Rows.LastObject).Cells[i] = cellValue;
public void Add(PdfPCell cellValue)
{
MigraRow row = null;
if (currentRowCellIndex == Columns.Count || Rows.Count == 0)
{
row = this.AddRow();
currentRowCellIndex = 0;
}
currentRowCellIndex += cellValue.Colspan;
int cellCount = ((MigraRow)Rows.LastObject).Cells.Count;
int celIndex = cellCount == 0 ? 0 : cellCount - 1;
var cell = ((MigraRow)Rows.LastObject).Cells[celIndex];
cell = cellValue.Clone();
cell.Elements = cellValue.Elements;
//((MigraRow)Rows.LastObject).Cells[celIndex]. = cellValue.Borders.Clone();
//((MigraRow)Rows.LastObject).Cells[celIndex].Borders = cellValue.Borders.Clone();
//((MigraRow)Rows.LastObject).Cells[celIndex].Elements = cellValue.Elements.Clone();
//((MigraRow)Rows.LastObject).Cells[celIndex].Shading.Color = cellValue.BackgroundColor;
//((MigraRow)Rows.LastObject).Cells[celIndex].MergeRight = cellValue.Colspan;
//para = ((Paragraph)cell.Elements.LastObject).Clone();
}
this solution doesnt work because ...Cells[i]...
is read only.
but I need to do something akin to this, is it possible?
As you can see I know that I can pass the values in each property to the Cells[i], but I don't like that solution.
Ps. in the presented code the PdfPCell is just a MigraDoc cell with some added functions by me, it can be used as a regular MigraDoc cell.