3
Answers

how to rowspan DataGridView in vb.net

tin zar

tin zar

9y
2.3k
1

hi,

  how to rowspan DataGridView in vb.net.

I tried the following code,but  RowSpan error occured. 
 
  For i As Integer = DGGrid.Rows.Count - 1 To 1 Step -1
            Dim row As DataGridViewRow = DGGrid.Rows(i)
            Dim previousRow As DataGridViewRow = DGGrid.Rows(i - 1)
 
            For j As Integer = 0 To row.Cells.Count - 1           
                If previousRow.Cells(j).RowSpan = 0 Then
                    If row.Cells(j).RowSpan = 0 Then
                        previousRow.Cells(j).RowSpan += 2
                    Else
                        previousRow.Cells(j).RowSpan = row.Cells(j).RowSpan + 1
                    End If
                    row.Cells(j).Visible = False
                End If              
            Next
        Next
 
Please help. 
Answers (3)