Spread Windows Forms 17
In This Topic
    Creating Borders with Diagonal Lines
    In This Topic

    You can create cell borders with diagonal lines as shown in the following image.

    creating cell borders with diagonal lines

    You can also display the diagonal lines in a cell border that is part of a shape as displayed in the following image.

    Displaying diagonal lines in a cell border

    The cell must have a border and the text orientation must not be zero. The EnableDiagonalLine property should also be set to true.

    The ComplexBorder class also allows you to create diagonal border lines in the cell.

    Using Code

    1. Create a text cell.
    2. Set the TextOrientation property.
    3. Set the TextRotationAngle property.

    Example

    This example code creates a text cell with a diagonal border.

    C#
    Copy Code
    fpSpread1.Sheets[0].Cells[1, 3].Text = "Test"; //Cell has to have value
    fpSpread1.Sheets[0].Cells[1, 3].Border = new FarPoint.Win.ComplexBorder(new FarPoint.Win.ComplexBorderSide(Color.Red, 2));// Cell has to have border
    
    FarPoint.Win.Spread.CellType.TextCellType cellType = new FarPoint.Win.Spread.CellType.TextCellType();
    cellType.TextOrientation = FarPoint.Win.TextOrientation.TextRotateCustom;
    cellType.TextRotationAngle = 60; // Cell has to have rotation angle to see the effect.
    fpSpread1.Sheets[0].Cells[1, 3].CellType = cellType;
    fpSpread1.Sheets[0].EnableDiagonalLine = true;
    
    VB
    Copy Code
    fpSpread1.Sheets(0).Cells(1, 3).Text = "Test" 'Cell has to have value
    fpSpread1.Sheets(0).Cells(1, 3).Border = New FarPoint.Win.ComplexBorder(New FarPoint.Win.ComplexBorderSide(Color.Red, 2)) ' Cell has to have border
    
    Dim cellType As New FarPoint.Win.Spread.CellType.TextCellType()
    cellType.TextOrientation = FarPoint.Win.TextOrientation.TextRotateCustom
    cellType.TextRotationAngle = 60 ' Cell has to have rotation angle to see the effect.
    fpSpread1.Sheets(0).Cells(1, 3).CellType = cellType
    fpSpread1.Sheets(0).EnableDiagonalLine = True
    

    Example

    This example code creates a text cell with a diagonal border and a shape that contains the cell.

    C#
    Copy Code
    fpSpread1.Sheets[0].Cells[1, 3].Text = "Test"; //Cell has to have value
    fpSpread1.Sheets[0].Cells[1, 3].Border = new FarPoint.Win.ComplexBorder(new FarPoint.Win.ComplexBorderSide(Color.Red, 2));// Cell has to have border
    
    FarPoint.Win.Spread.CellType.TextCellType cellType = new FarPoint.Win.Spread.CellType.TextCellType();
    cellType.TextOrientation = FarPoint.Win.TextOrientation.TextRotateCustom;
    cellType.TextRotationAngle = 60; // Cell has to have rotation angle to see the effect.
    fpSpread1.Sheets[0].Cells[1, 3].CellType = cellType;
    
    FarPoint.Win.Spread.DrawingSpace.TriangleShape a = new FarPoint.Win.Spread.DrawingSpace.TriangleShape();
    a.BackColor = Color.Blue;
    fpSpread1.ActiveSheet.AddShape(a, 1, 1);
    FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape test = new FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape();
    test.Formula = "B1:E6";
    test.Location = new System.Drawing.Point(20, 20);
    fpSpread1.Sheets[0].AddShape(test);
    fpSpread1.Sheets[0].EnableDiagonalLine = true;
    
    VB
    Copy Code
    fpSpread1.Sheets(0).Cells(1, 3).Text = "Test" 'Cell has to have value
    fpSpread1.Sheets(0).Cells(1, 3).Border = New FarPoint.Win.ComplexBorder(New FarPoint.Win.ComplexBorderSide(Color.Red, 2)) ' Cell has to have border
    
    Dim cellType As New FarPoint.Win.Spread.CellType.TextCellType()
    cellType.TextOrientation = FarPoint.Win.TextOrientation.TextRotateCustom
    cellType.TextRotationAngle = 60 ' Cell has to have rotation angle to see the effect.
    fpSpread1.Sheets(0).Cells(1, 3).CellType = cellType
    
    Dim a As New FarPoint.Win.Spread.DrawingSpace.TriangleShape()
    a.BackColor = Color.Blue
    fpSpread1.ActiveSheet.AddShape(a, 1, 1)
    Dim test As New FarPoint.Win.Spread.DrawingSpace.SpreadCameraShape()
    test.Formula = "B1:E6"
    test.Location = New System.Drawing.Point(20, 20)
    fpSpread1.Sheets(0).AddShape(test)
    fpSpread1.Sheets(0).EnableDiagonalLine = True
    
    See Also