T
TJS
When trying to delete a row from a datagrid I get this error on every record
regardless of record selected to delete.
"Index 7 is not non-negative and below total rows count."
there are 8 rows in the table being edited so index 7 should be a valid
number
========= the offending code =================
Private _dataGridData As New DataTable()
Private _dataGridView As New DataView()
......
Private Sub DeleteRow(rowIndex As Integer)
_dataGridView = _dataGridData.DefaultView
If _dataGridData.Rows.Count >= rowIndex Then
' Delete row from datatable
Dim row As DataRow = _dataGridView(rowIndex).Row
row.Delete() '<=== won't go past this point
End If
End sub
regardless of record selected to delete.
"Index 7 is not non-negative and below total rows count."
there are 8 rows in the table being edited so index 7 should be a valid
number
========= the offending code =================
Private _dataGridData As New DataTable()
Private _dataGridView As New DataView()
......
Private Sub DeleteRow(rowIndex As Integer)
_dataGridView = _dataGridData.DefaultView
If _dataGridData.Rows.Count >= rowIndex Then
' Delete row from datatable
Dim row As DataRow = _dataGridView(rowIndex).Row
row.Delete() '<=== won't go past this point
End If
End sub