The Issue Is
I am adding Rows in a Datagridview
programmatically on Button Click
As
Dim s As Integer = Val(txtSlNo.Text)
Dim c As Integer
If s = 0 Then
c = dgvInvoice.Rows.Count
s = c + 1
dgvInvoice.Rows.Add()
Else
c = s - 1
End If
dgvInvoice.Rows(c).Cells(0).Value = s.ToString()
This Snippet is on add Button click which is adding Row
and assigning Serial No to each row.
Next I have a button Delete Row .On the click event of Delete Button
am removing the Selected Rows as Below
For Each row As DataGridViewRow In dgvInvoice.SelectedRows
Dim response As DialogResult = _
MessageBox.Show( _
"Are you sure you want to delete this row?", _
"Delete row?", _
MessageBoxButtons.YesNo, _
MessageBoxIcon.Question, _
MessageBoxDefaultButton.Button2)
If (response = DialogResult.No) Then
Else
dgvInvoice.Rows.Remove(row)
End If
Next
Now the Problem is If the user Added Five rows In DatagridView
and removed the Row having Serial no 3 or any from the Datagridview.
I want that Serial no should also change Accordingly.
I think you understanding my Question.
How to Acheive this
Please assist.