PDFsharp & MigraDoc Forum
https://forum.pdfsharp.net/

Tables, Set.Edge and a problem with rows overlapping
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2305
Page 1 of 1

Author:  wittag [ Mon Jan 21, 2013 3:42 pm ]
Post subject:  Tables, Set.Edge and a problem with rows overlapping

I found out that changing the int rows (4th element) doesn't affect the rows of a table that will be rendered. Only if I put a number larger than the number of rows I get an exception. This makes sense, but why not to get less rows rendered in case that int rows is less than my rows?
public void SetEdge(int clm, int row, int clms, int rows, Edge edge, BorderStyle style, Unit width, Color clr);

I create the rows using the following loop

Code:
for (int rows = 0; rows < Table1_1.Count; rows++)
            {
                row = table_1.AddRow();
                row.HeadingFormat = true;
                row.Format.Alignment = ParagraphAlignment.Center;
                row.Format.Font.Name = "Arial";
                row.Format.Font.Size = 6;
                row.Format.Font.Bold = false;
                if (rows % 2 != 0)
                {
                    row.Shading.Color = TableBlue;
                }
                else
                {
                    row.Shading.Color = TableGray;
                }
                row.Cells[0].AddParagraph(Table1_1[rows]);
                row.Cells[0].Format.Alignment = ParagraphAlignment.Left;
                row.Cells[1].AddParagraph(Table1_2[rows]);
                row.Cells[1].Format.Alignment = ParagraphAlignment.Center;
            }

where
Code:
List<string> Table1_1 = new List<string>();

filled with 14 elements

Furthermore if I render a second table on another position in the page, the first table becomes as its last row the header of the second. Is this a known (or not) bug, or am I messing around with something?

I can provide the solution if there is interest.

Author:  Thomas Hoevel [ Mon Jan 21, 2013 4:30 pm ]
Post subject:  Re: Tables, Set.Edge and a problem with rows overlapping

Hi!
wittag wrote:
I found out that changing the int rows (4th element) doesn't affect the rows of a table that will be rendered.
A table will be rendered with all its row. You can remove rows later if you created too many.

SetEdge just sets a visible border around specific table cells. It's not intended to remove rows from your table.

In PDF there are no known problems with two tables.

When creating RTF, make sure you have a paragraph between two tables.

Author:  wittag [ Tue Jan 22, 2013 7:30 am ]
Post subject:  Re: Tables, Set.Edge and a problem with rows overlapping

Hi,

it was my mistake, I declared
Code:
Row row = table_1.AddRow();

and then used it for the second table too.
The correct way is:
Code:
Row row_1 = table_1.AddRow();
Row row_2 = table_2.AddRow();


I put here the solution in case someone else has the same problem.

It needs sometime to get used to the many options this library has, but that's what I like, because I am able to create the document the way I want it.

Thanks for your help.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/