Hi, i want to draw a right border in cell of a row with top margin = 7; if i do:
row = grid.AddRow();
row.Margins.Top = 7;
...
cell = row.AddCell();
cell.Borders.Right = new Border(new Pen(Colors.Black, DashStyle.Solid));
.... the border isn't drawn in the "margins zone". How can I do?
Are you saying that the borders are drawn too far vertically so that they don't respect the top margins? It's possible that the cell is taking up too much height, but I can't really say without seeing more code as to how you're building your grid. Can you post a small sample so that I can look further into it? One debugging tip for seeing how much width or height an element is taking up is to set the Background to something obvious (i.e. cell.Background = new Background(Infragistics.Documents.Graphics.Brushes.Green)).
The sample that I used to test this was correctly honoring the margins of the top of the row:
private void button1_Click(object sender, EventArgs e){ Report report = new Report(); ISection section = report.AddSection(); IText text = section.AddText(); text.Borders = new Borders(Infragistics.Documents.Graphics.Pens.Blue); text.AddContent("Header"); IGrid grid = section.AddGrid(); IGridColumn col = grid.AddColumn(); col.Width = new FixedWidth(30); IGridRow row = grid.AddRow(); row.Margins.Top = 7; IGridCell cell = row.AddCell(); cell.Background = new Background(Infragistics.Documents.Graphics.Brushes.Green); cell.Borders.Right = new Border(Infragistics.Documents.Graphics.Pens.Red); cell.AddText().AddContent("First Row"); row = grid.AddRow(); row.Margins.Top = 7; cell = row.AddCell(); cell.Background = new Background(Infragistics.Documents.Graphics.Brushes.Gray); cell.Borders.Right = new Border(Infragistics.Documents.Graphics.Pens.Red); cell.AddText().AddContent("Second row"); report.Publish("Test.pdf", FileFormat.PDF); Process.Start("Test.pdf");}
-Matt
yes, that's exactly what I want to say. With your code, there's a space between the 2 cells, and I like it, but I want that borders haven't margin, i would like that the borders become united.
p.s.: sorry for my bad english
My mistake, I misread your original post. In order to do this, you would have to set the margins on a sub-element, like an IText element, instead of on the row itself, since any child elements will be affect by the parent's Margins. Here is my updated test code:
private void button1_Click(object sender, EventArgs e){ Report report = new Report(); ISection section = report.AddSection(); IText text = section.AddText(); text.Borders = new Borders(Infragistics.Documents.Graphics.Pens.Blue); text.AddContent("Header"); IGrid grid = section.AddGrid(); IGridColumn col = grid.AddColumn(); col.Width = new FixedWidth(30); IGridRow row = grid.AddRow(); IGridCell cell = row.AddCell(); cell.Borders.Right = new Border(Infragistics.Documents.Graphics.Pens.Red); text = cell.AddText(); text.Background = new Background(Infragistics.Documents.Graphics.Brushes.Green); text.Margins.Top = 7; text.AddContent("First Row"); row = grid.AddRow(); cell = row.AddCell(); cell.Borders.Right = new Border(Infragistics.Documents.Graphics.Pens.Red); text = cell.AddText(); text.Background = new Background(Infragistics.Documents.Graphics.Brushes.Gray); text.Margins.Top = 7; text.AddContent("Second row"); report.Publish("Test.pdf", FileFormat.PDF); Process.Start("Test.pdf");}