Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
415
Changing tableCell border for one cell changes for all cells
posted

In my report, I have to put some conditions to check to some columns for special values and based on this I have to add a thick border on the top of that cell only. In this case, I am checking for propName == "ClassCode" and based on the content I am trying to add top border for that cell only (not in all cell for that column).

My problem is when I change the top border, its applied to entire report where ever I am using border. Below is my code:

var dt=string.empty;

private void AddRowCell(ITableRow tableRow, string propName, string dt)
{

var tableCell = tableRow.AddCell();

tableCell.Borders = bordersStyle;//new Borders(new Pen(new Color(200, 200, 200), (float)0.5, DashStyle.Solid));

//set top border for class code
if (propName == "ClassCode")
{

if (clsCode != dt)
{
    //change the top border for this cell only
    tableCell.Borders.Top = new Border(new Pen(new Color(50, 50, 50), (float)4, DashStyle.Solid));
}

clsCode = dt;

}

IText cellText = tableCell.AddText();
cellText.AddContent(dt);

}

I am using 2014.2 report.dll. Please help me on this.

  • 415
    Suggested Answer
    posted

    I was trying few more things and I found a work around. Basically I have to define all 4 sides of border even though I dont need them.

    //this code works fine

    tableCell.Borders = new Borders(
                                  new Pen(new Color(200, 200, 200), (float)0.5, DashStyle.Solid),
                                  new Pen(new Color(200, 200, 200), (float)0.5, DashStyle.Solid),
                                  new Pen(new Color(50, 50, 50), (float)2, DashStyle.Solid), //top border
                                  new Pen(new Color(200, 200, 200), (float)0.5, DashStyle.Solid));

    //this code doesn't work

    tableCell.Borders = new Borders(new Pen(new Color(200, 200, 200), (float)0.5, DashStyle.Solid));
    tableCell.Borders.Top = new Border(new Pen(new Color(50, 50, 50), (float)4, DashStyle.Solid));

    Is there any issue in below code which doesn't just change the top border?