title: VB.NET DataGridView Cell Serial Number regenerate
body: <p>May be this question is not much important for you but I am facing problem in this. I have a DataGridView in which I add rows by.....</p>
  
  <pre><code>If Me.Dgv.Rows.Count = 0 Then
      SlNo = 1
  Else
      SlNo = Me.Dgv.Rows.Count + 1
  End If
  
  Me.Dgv.Rows.Add(SlNo, ItemId, ItemName, Qty, ItemRate, Amt)
  </code></pre>
  
  <p>and the rows display like...</p>
  
  <pre><code>-----------------------------------------------------------------
  |  Sl No  |  Item Id  |  Item Name  |  Qty  |  Rate  |  Amount  |
  -----------------------------------------------------------------
  |    1    |     6     |  Item6      |  10   |  100.00|   1000.00|
  -----------------------------------------------------------------
  |    2    |     8     |  Item8      |  10   |  200.00|   2000.00|
  -----------------------------------------------------------------
  |    3    |     2     |  Item2      |  10   |  300.00|   3000.00|
  -----------------------------------------------------------------
  |    4    |     16    |  Item16     |  10   |  400.00|   4000.00|
  -----------------------------------------------------------------
  </code></pre>
  
  <p>Now I want to clear <code>Row (Sl No. - 2)</code> but I want to maintain the serial numbers like below.</p>
  
  <pre><code>-----------------------------------------------------------------
  |  Sl No  |  Item Id  |  Item Name  |  Qty  |  Rate  |  Amount  |
  -----------------------------------------------------------------
  |    1    |     6     |  Item6      |  10   |  100.00|   1000.00|
  -----------------------------------------------------------------
  |    2    |     2     |  Item2      |  10   |  300.00|   3000.00|
  -----------------------------------------------------------------
  |    3    |     16    |  Item16     |  10   |  400.00|   4000.00|
  -----------------------------------------------------------------
  </code></pre>
  
  <p>or I want to clear <code>Row (Sl No. - 1)</code> and want to maintain the serial numbers like</p>
  
  <pre><code>-----------------------------------------------------------------
  |  Sl No  |  Item Id  |  Item Name  |  Qty  |  Rate  |  Amount  |
  -----------------------------------------------------------------
  |    1    |     8     |  Item8      |  10   |  200.00|   2000.00|
  -----------------------------------------------------------------
  |    2    |     2     |  Item2      |  10   |  300.00|   3000.00|
  -----------------------------------------------------------------
  |    3    |     16    |  Item16     |  10   |  400.00|   4000.00|
  -----------------------------------------------------------------
  </code></pre>
  
  <p>It means I want to delete/clear a row from <code>DataGridView</code> maintaining the serial numbers.</p>
  
  <p>I tried like....</p>
  
  <pre><code>    Private Sub DgvAutoSerialNumbering()
      Dim SlNumber As Integer = 0
      If Me.Dgv.Rows.Count = 0 Then
          SlNumber = 1
      ElseIf Me.Dgv.Rows.Count &gt; 0 Then
          For i As Integer = 0 To Me.Dgv.Rows.Count - 1
              SlNumber = Me.Dgv.Rows.Count
              Me.Dgv.CurrentRow.Cells(0).Value = SlNumber
          Next
      End If
  End Sub
  </code></pre>
  
  <p>But failed to get the output.</p>
  
  <p>How could I do this ?</p>
  
  <p>Thanks in advance</p>