title: how to count columns and rows dynamically of vb.net
body: <p>Good morning All...
  i need help, how to count columns and rows of datagrid in vb.net dynamically? i have made but still statis if i add new data, result of calculation is not move to new column. i have coding which i have made..</p>
  
  <pre><code>    DGV2.Columns.Add("Total Km", "Total Km")
      'DGV2.Columns.Add("Percentage", "Percentage")
      Dim bykdata As Integer = DGV2.RowCount - 1
      Dim bykkolom As Integer = DGV2.ColumnCount + 1
      Dim a As Integer
      Dim b As Integer
      Dim c As Integer
      Dim d As Integer
      Dim g As Integer
      Dim f As Integer
      Dim h As Integer
      Dim i As Integer 'looping
      Dim j As Integer 'looping
      Dim k As Integer
      Dim m As Integer
      Dim n As Integer
      Dim o As Integer
      Dim v As Integer
      'Dim w As Integer
      'Dim x As Integer
      Dim tot As Integer
  
      'ambildata
      For i = 0 To bykdata
          v = DGV2.Item(2, i).Value
          a = DGV2.Item(3, i).Value
          b = DGV2.Item(4, i).Value
          c = DGV2.Item(5, i).Value
          d = DGV2.Item(6, i).Value
          g = DGV2.Item(7, i).Value
          f = DGV2.Item(8, i).Value
          h = DGV2.Item(9, i).Value
          k = DGV2.Item(10, i).Value
          m = DGV2.Item(11, i).Value
          n = DGV2.Item(12, i).Value
          o = DGV2.Item(13, i).Value
          c = v + a + b + c + d + g + f + h + k + m + n + o
          DGV2.Item(14, i).Value = c.ToString
      Next
  
      For j = 0 To bykdata
          a = DGV2.Item(3, j).Value
          tot = tot + a
          DGV2.Item(15, j).Value = tot.ToString
      Next
  </code></pre>