合并GridView中的单元格!

来源:互联网 发布:梦行的旅游cms系统 编辑:程序博客网 时间:2024/03/29 23:00

效果如下:

代码:

Private Sub GroupRows(ByVal GridView1 As GridView)

        Dim oldTc As TableCell

 

         oldTc = GridView1.Rows(0).Cells(0)

        Dim i As Integer

        For i = 1 To GridView1.Rows.Count - 1

            Dim tc As TableCell

             tc = GridView1.Rows(i).Cells(0)

            If oldTc.Text = tc.Text Then

                 tc.Visible = False

                If oldTc.RowSpan = 0 Then

                     oldTc.RowSpan = 1

                End If

                 oldTc.RowSpan += 1

                 oldTc.VerticalAlign = VerticalAlign.Middle

            Else

                 oldTc = tc

            End If

        Next

    End Sub

原创粉丝点击