View previous topic :: View next topic |
Author |
Message |
NateDawg
Joined: 01 Apr 2008 Posts: 6
|
Posted: Fri Apr 04, 2008 5:36 am Post subject: MigrDoc Table in a row? |
|
|
Is it possible to add a table to a row or cell of another table? I can't seem to find a way to do it.
I have a table of records that are retrieved from a database and each record has a few child records that I need to display in line. the child records have a different number of columns and they are a different width. So I figured a table in a table was the best solution (like in Html code).
Is this possible?
thanks,
-- Nathan Rover |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Mon Apr 07, 2008 7:52 am Post subject: |
|
|
This can be done and I did it a few months ago, but don't remember the trick.
Don't look for an AddTable method at the table cell. Use "new Table()" and the generic Add method. I don't recall if I added the table directly to the cell or if I added a paragraph to the cell and the table to the paragraph.
Related topic (uses a TextFrame for that purpose which is not generally needed to have nested tables) _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
NateDawg
Joined: 01 Apr 2008 Posts: 6
|
Posted: Tue Apr 08, 2008 8:57 pm Post subject: I'm still getting an error. |
|
|
I've tried to add it to the cell and to a paragraph and I'm getting an error: Overload resolution failed because no accessible 'Add' can be called with these arguments.
here is my code section:
Code: | For Each DTRow As DataRow In Students.Rows
Dim tbl As New MigraDoc.DocumentObjectModel.Tables.Table()
tbl.Borders.Width = 0.75
Column = tbl.AddColumn(MigraDoc.DocumentObjectModel.Unit.FromInch(1.25))
Column.Format.Alignment = ParagraphAlignment.Center
Row = tbl.AddRow()
Cell = Row.Cells(0)
Cell.AddParagraph(i.ToString())
Row = Table.AddRow()
Cell = Row.Cells(0)
Cell.MergeRight = 5
Paragraph = Cell.AddParagraph()
Paragraph.Add(tbl)
i += 1
Next |
The line that causes the error is "Paragraph.Add(tbl)" "tbl" is the name of the table I'm trying to insert in to "table" which is the main table. Each "tbl" will be about 4 or 5 rows, with different columns than the main table. My hope was that if a complete "tbl" did not fit on a page it would move to the next page. I can't figure out how to do that with just one table. Any suggestions?
Thanks,
-- Nathan Rover |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Wed Apr 09, 2008 7:35 am Post subject: Re: I'm still getting an error. |
|
|
NateDawg wrote: | My hope was that if a complete "tbl" did not fit on a page it would move to the next page. I can't figure out how to do that with just one table. Any suggestions? |
I don't recall how I managed to get nested tables when I tried it about two years ago ...
Today I tried it with a textframe in a cell:
Code: | Cell cell = row1.Cells[0];
TextFrame tf = cell.AddTextFrame();
Table table2 = tf.AddTable();
table2.Borders.Width = 1;
table2.AddColumn();
row = table2.AddRow();
row.Cells[0].AddParagraph("*** Test ***");
|
This works and should do the trick (if the nested tables are small enough to fit on a page). _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
|