Column Header Borders

Posted by: sameek on 8 September 2017, 2:38 pm EST

  • Posted 8 September 2017, 2:38 pm EST

    We are upgrading to the latest version of spread 5.0 from a much earlier version.  Before when we had a column header with two rows we were able to have the following code and there would be no border on the bottom of the first row.

    After upgrading however we see there is a line between the first and second row.  I was wondering how do we get that line in between to dissapear?

    Dim topside As New FarPoint.Win.ComplexBorderSide(Drawing.Color.Black, 0)

    Dim leftside As New FarPoint.Win.ComplexBorderSide(Drawing.Color.Black, 0)

    Dim rightside As New FarPoint.Win.ComplexBorderSide(Drawing.Color.Black, 0)

    Dim bottomside As New FarPoint.Win.ComplexBorderSide(Drawing.Color.LightGray, 1)

    Dim border As New FarPoint.Win.ComplexBorder(leftside, topside, rightside, bottomside)

    spread.sheets(0).ColumnHeader.Cells(spread.sheets(0).ColumnHeader.RowCount - 2, OfferingCode).Value = "Offering"

    spread.sheets(0).ColumnHeader.Cells(spread.sheets(0).ColumnHeader.RowCount - 1, OfferingCode).Value = "Code"

    spread.sheets(0).ColumnHeader.Cells(spread.sheets(0).ColumnHeader.RowCount - 2, OfferingCode).Border = border

  • Replied 8 September 2017, 2:38 pm EST


    If you want to remove the gridline between two
    rows in the column header, for doing so you need to create a new
    gridline with GridLineType to be null and set it to be the horizontal
    gridline of the column header. code for same is given below:-

    fpSpread1.ActiveSheet.ColumnHeader.DefaultStyle.Renderer = new FarPoint.Win.Spread.CellType.ColumnHeaderRenderer();
    fpSpread1.VisualStyles = FarPoint.Win.VisualStyles.Off;
    FarPoint.Win.Spread.GridLine cgdln = new FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.None);

    fpSpread1.Sheets[0].ColumnHeader.HorizontalGridLine = cgdln;

    But this would remove the line from the complete column header. In
    case you want to have the same behaviour in only one column and want to
    show the GridLine in remaining columns then firstly you have to set the
    gridline to none and then set the border for each cell in the other column
    header cells. The code for same is:

     fpSpread1.ActiveSheet.ColumnHeader.DefaultStyle.Renderer = new FarPoint.Win.Spread.CellType.ColumnHeaderRenderer();
     fpSpread1.VisualStyles = FarPoint.Win.VisualStyles.Off;
     FarPoint.Win.Spread.GridLine cgdln = new FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.None);

     fpSpread1.Sheets[0].ColumnHeader.HorizontalGridLine = cgdln;
     fpSpread1.Sheets[0].ColumnHeader.Cells[fpSpread1.Sheets[0].ColumnHeader.RowCount - 2, 1].Value = "Offering";
     fpSpread1.Sheets[0].ColumnHeader.Cells[fpSpread1.Sheets[0].ColumnHeader.RowCount - 1, 1].Value = "Code";

     FarPoint.Win.ComplexBorderSide topside = new FarPoint.Win.ComplexBorderSide(System.Drawing.Color.Black,0);
     FarPoint.Win.ComplexBorderSide leftside = new FarPoint.Win.ComplexBorderSide(System.Drawing.Color.Black, 0);

     FarPoint.Win.ComplexBorderSide rightside = new FarPoint.Win.ComplexBorderSide(System.Drawing.Color.Black, 0);
     FarPoint.Win.ComplexBorderSide bottomside = new FarPoint.Win.ComplexBorderSide(System.Drawing.Color.Red, 1);

     FarPoint.Win.ComplexBorder border = new FarPoint.Win.ComplexBorder(leftside, topside, rightside, bottomside);
     fpSpread1.ActiveSheet.ColumnHeader.RowCount = 2;
    fpSpread1.ActiveSheet.ColumnCount = 5; // "For setting the border"

     for (int j = 0; j < fpSpread1.ActiveSheet.ColumnCount; j++)
           if (j != 1)
                   fpSpread1.ActiveSheet.ColumnHeader.Cells[0, j].Border = border;

    Hope it will help you. Thanks.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels