找回密码
 立即注册

QQ登录

只需一步,快速开始

jplzj
论坛元老   /  发表于:2012-9-7 10:55  /   查看:6289  /  回复:8
FP单元格边框能否实现每条边设置不一致
如:左边为1的虚线,右边为1的实线,上边为1.5红色虚线,下边为2红色实线 。

8 个回复

倒序浏览
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-9-7 12:24:00
沙发
可以通过以下来设置:
  1.     ComplexBorderSide lb = new ComplexBorderSide(Color.Black,1,System.Drawing.Drawing2D.DashStyle.Dash);
  2.     ComplexBorderSide tb = new ComplexBorderSide(Color.Red,2,System.Drawing.Drawing2D.DashStyle.Dash);
  3.     ComplexBorderSide rb = new ComplexBorderSide(Color.Black,1);
  4.     ComplexBorderSide bb = new ComplexBorderSide(Color.Black,2);
  5.     fpSpread1.ActiveSheet.Cells[1, 2].Border = new FarPoint.Win.ComplexBorder(lb, tb, rb, bb);
复制代码
回复 使用道具 举报
jplzj
论坛元老   /  发表于:2012-9-7 14:06:00
板凳
如何获取单元格每边的边框样式?能否只设一个边,其他边保持原状态?
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-9-7 14:50:00
地板
需要将Border转换为一个Border类型,然后就可以取出各边的设置:
  1.     (fpSpread1.ActiveSheet.Cells[1,1].Border as FarPoint.Win.ComplexBorder).Left
  2.     (fpSpread1.ActiveSheet.Cells[1,1].Border as FarPoint.Win.ComplexBorder).Top
  3.     (fpSpread1.ActiveSheet.Cells[1,1].Border as FarPoint.Win.ComplexBorder).Right
  4.     (fpSpread1.ActiveSheet.Cells[1,1].Border as FarPoint.Win.ComplexBorder).Bottom
复制代码
回复 使用道具 举报
jplzj
论坛元老   /  发表于:2012-9-7 20:10:00
5#
无法将类型为“FarPoint.Win.ComplexBorder”的对象强制转换为类型“FarPoint.Win.ComplexBorderSide”。
代码为:
cell.Border = New FarPoint.Win.ComplexBorder(New FarPoint.Win.ComplexBorder(FpSpread1.ActiveSheet.Cells(FpSpread1.ActiveSheet.ActiveRowIndex + 1, FpSpread1.ActiveSheet.ActiveColumnIndex).Border).Left, lb, Nothing, Nothing)
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-9-10 18:18:00
6#
比如只需要设置底边框,可以使用下面的代码:
  1. Private Sub button1_Click(sender As Object, e As EventArgs)
  2.         Dim border As ComplexBorder = TryCast(fpSpread1.ActiveSheet.Cells(1, 1).Border, ComplexBorder)

  3.         Dim lb As ComplexBorderSide = border.Left
  4.         Dim tb As ComplexBorderSide = border.Top
  5.         Dim rb As ComplexBorderSide = border.Right
  6.         Dim bb As ComplexBorderSide = border.Bottom
  7.         Dim newborder As New ComplexBorderSide(Color.Red, 3)

  8.         fpSpread1.ActiveSheet.Cells(1, 1).Border = New FarPoint.Win.ComplexBorder(lb, tb, rb, newborder)

  9. End Sub
复制代码
回复 使用道具 举报
jplzj
论坛元老   /  发表于:2012-9-10 19:49:00
7#
OK,又学了一招
回复 使用道具 举报
jplzj
论坛元老   /  发表于:2012-9-23 21:46:00
8#
边框设置完整代码:

Private Sub SetCellBorderAll()
        Dim sv As FarPoint.Win.Spread.SheetView = FpSpread1.ActiveSheet
        If sv Is Nothing Then
            Exit Sub
        End If
        Dim border As ComplexBorder
        Dim StarRow As Integer
        Dim StarColumn As Integer
        Dim EndRow As Integer
        Dim Endcolumn As Integer
        Dim cr As FarPoint.Win.Spread.Model.CellRange

        Dim lb As FarPoint.Win.ComplexBorderSide = New FarPoint.Win.ComplexBorderSide(Color.Black, 1)
        Dim tb As ComplexBorderSide = New ComplexBorderSide(Color.Black, 1)
        If sv.GetSelections().Length > 0 Then

            cr = sv.GetSelections(0)
            StarRow = cr.Row
            StarColumn = cr.Column
            EndRow = StarRow + cr.RowCount
            Endcolumn = StarColumn + cr.ColumnCount
            sv.Cells(cr.Row, cr.Column, cr.RowCount + cr.Row - 1, cr.ColumnCount + cr.Column - 1).Border = New FarPoint.Win.ComplexBorder(Nothing, Nothing, tb, tb)
           
            If StarRow = 0 Then

                sv.Cells(0, StarColumn, 1, Endcolumn - 1).Border = New FarPoint.Win.ComplexBorder(Nothing, tb, tb, tb)
            Else

                For i As Integer = 0 To cr.ColumnCount - 1
                    border = TryCast(FpSpread1.ActiveSheet.Cells(StarRow - 1, StarColumn + i).Border, ComplexBorder)
                    If Not border Is Nothing Then
                        sv.Cells(StarRow - 1, StarColumn + i).Border = New FarPoint.Win.ComplexBorder(border.Left, Nothing, border.Right, tb)
                    Else
                        sv.Cells(StarRow - 1, StarColumn + i).Border = New FarPoint.Win.ComplexBorder(Nothing, Nothing, Nothing, tb)
                    End If

                Next

           
            End If

        End If



        If StarColumn = 0 Then

            sv.Cells(StarRow, 0, EndRow, 0).Border = New FarPoint.Win.ComplexBorder(lb, Nothing, lb, tb)
        Else

            For i As Integer = 0 To cr.RowCount - 1
                border = TryCast(FpSpread1.ActiveSheet.Cells(cr.Row + i, cr.Column - 1).Border, ComplexBorder)
                If Not border Is Nothing Then
                    sv.Cells(cr.Row + i, cr.Column - 1).Border = New FarPoint.Win.ComplexBorder(border.Left, Nothing, tb, border.Bottom)
                Else
                    sv.Cells(cr.Row + i, cr.Column - 1).Border = New FarPoint.Win.ComplexBorder(Nothing, Nothing, tb, Nothing)
                End If


            Next

        End If
    End Sub
回复 使用道具 举报
ZenosZeng讲师达人认证 悬赏达人认证
超级版主   /  发表于:2012-9-25 17:44:00
9#
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部