DataGrid Merge Line

Source: Internet
Author: User
DataGrid Private Sub Unitdatagriditem (ByVal Intcell as Integer)
Dim Objdatagriditem as DataGridItem
Dim strCell1 as String = ""
Dim strCell2 as String = ""
Dim Objliteralcontrol as LiteralControl
Dim Intspan as Integer = 1
Dim Objdatagriditemtospan as DataGridItem
Dim I, J as Integer
Dim strtemp as String
For i = 0 to Datagrid1.items.count-1
Intspan = 1
Objliteralcontrol = CType (Datagrid1.items (i). Cells (Intcell). Controls (0), LiteralControl)
STRCELL1 = Objliteralcontrol.text

For j = i + 1 to datagrid1.items.count-1
Objliteralcontrol = CType (Datagrid1.items (j). Cells (Intcell). Controls (0), LiteralControl)
StrCell2 = Objliteralcontrol.text
If strCell1 = StrCell2 Then
Intspan + 1
Datagrid1.items (i). Cells (Intcell). RowSpan = Intspan
Datagrid1.items (j). Cells (Intcell). Visible = False
Else
Exit for
End If
Next
i = J-1
Next

End Sub
In addition to setting the rowspan, the visible of the following line is set to false, otherwise it does not work, and a column is created below. Each cell in this DataGrid contains a LiteralControl, if it is not, Just use Datagrid1.items (i) directly. Cells (Intcell). Text can be. The reference Intcell, which is the column to merge.




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.