9CBS - Document Center - .NET title merged DataGrid content The same cell Jxf_YX (original) Keyword DataGrid
Sometimes, we have to merge the same cells in a column. As shown in the figure: After the merged rendering: Subsencing () DIM I AS INTEGER DIM J AS INTEGER DIM I AS INTEGER, NOWSPAN AS INTEGER = 0 DIM STRTEMP AS STRING FOR i = 0 to DGRID. Items.count - 1 INTSPAN = 1 'Gets the first column (color), content in the first line cell. Here is "red red". (DataGrid uses template column) strTemp = CType (DGrid.Items (i) .Cells (0) .controls (1), system.web.ui.webcontrols.label) .Text 'loop judgment. Determine the same content in the first column and the first line. Same as a mark, INTSPAN plus a for j = i 1 to dgrid.Items.count - 1 if string.compare (strtemp, ctype (dgrid.Items (j) .cells (1) .controls (1), System.Web .Ui.webcontrols.label) .text) = 0 THEN INTSPAN = 1 'Use the DataGrid's ROWSPAN attribute. (Set the number of lines across the cells in the control to INTSPAN) DGRID.Items (i) .cells (0) .rowspan = INTSPAN 'That the same cell hides DGRID.Items (j) .Cells (0) .visible = false Else EXIT for end if next 'i = j - 1 I original NOWSPAN = INTSPAN' After modifying the number of cycles, I = Nowspan - 1 Next End Sub ======= 聽聽 = Bind data to DataGrid ........ spangrid () end sub ================== Add content. Merged in other columns ======== In the case of the first column already merged, the same cells as the same content as long as I = J-1 is made before I = J-1. . The following is the rendering: