tin zar

tin zar

  • NA
  • 13
  • 14.7k

how to rowspan DataGridView in vb.net

Jun 30 2015 10:29 PM

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)