| PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
| Add border to single column https://forum.pdfsharp.net/viewtopic.php?f=2&t=2725 |
Page 1 of 1 |
| Author: | Starnaus [ Fri Jan 31, 2014 6:46 pm ] |
| Post subject: | Add border to single column |
I am trying to add a right border to a single MirgraDoc table column if the source column is frozen. This works fine, until I add a top border to my header row. As soon as I touch the border of the header row, all of the cells in the header row gain the right border from the "frozen" column. How can I keep the non-frozen columns from inheriting the right border setting? Code: for (int i = 0; i < sourceTable.Columns.Count; i++)
{ SourceColumn srcCol = sourceTable.Columns[i]; MigraDoc.DocumentObjectModel.Tables.Column column = table.AddColumn(); if (srcCol .IsHFrozen && !srcCol .NextVisibleColumn.IsHFrozen) { column.Borders.Right.Color = new MigraDoc.DocumentObjectModel.Color(blue.A, blue.R, blue.G, blue.B); } } MigraDoc.DocumentObjectModel.Tables.Row headerRow = table.AddRow(); headerRow.HeadingFormat = true; headerRow.Borders.Top.Color = new MigraDoc.DocumentObjectModel.Color(blue.A, blue.R, blue.G, blue.B); headerRow.BottomPadding = 4; int colIndex = 0; double tableWidth = section.PageSetup.PageWidth.Point - section.PageSetup.LeftMargin.Point - section.PageSetup.RightMargin.Point; for (int i = 0; i < sourceTable.Columns.Count; i++) { SourceColumn srcCol = sourceTable.Columns[i]; String colName = srcCol.Name; headerRow.Cells[colIndex].AddParagraph(colName); double colPercent = gridCol.Width / (double)superGridControlData.Width; headerRow.Cells[colIndex].Column.Width = Unit.FromPoint((colPercent*tableWidth)+10); colIndex++; } |
|
| Author: | Thomas Hoevel [ Mon Feb 03, 2014 10:36 am ] |
| Post subject: | Re: Add border to single column |
In our application we set borders for cells (not for columns) and everything works as expected. Could be a bug. Could you provide a SSCCE that demonstrates the bug? |
|
| Author: | Starnaus [ Tue Feb 04, 2014 3:57 pm ] | ||
| Post subject: | Re: Add border to single column | ||
Please find attached a VS2012 project with a simple example. Running the program as is will create a PDF file with the first column having a blue right border. Un-commenting the two lines for the header row top and bottom border will result in a PDF that has a first column with a blue right border, and the header row having a blue top and bottom border, as well as every cell in the row having a right border. MigraDoc GDI 1.32.3885.0
|
|||
| Author: | Thomas Hoevel [ Tue Feb 04, 2014 4:45 pm ] |
| Post subject: | Re: Add border to single column |
It's a bug. I didn't fix it yet. But I have a work-around: Code: headerRow.Borders.Top.Color = new MigraDoc.DocumentObjectModel.Color(blue.A, blue.R, blue.G, blue.B); The third line disables the right border for all cells, the fourth line re-activates the right border for the first column.
headerRow.Borders.Bottom.Color = new MigraDoc.DocumentObjectModel.Color(blue.A, blue.R, blue.G, blue.B); headerRow.Borders.Right.Width = 0; headerRow.Cells[0].Borders.Right.Width = .5; |
|
| Author: | Starnaus [ Tue Feb 04, 2014 8:34 pm ] |
| Post subject: | Re: Add border to single column |
That works, thanks! |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|