Private Sub XamMenuItem_DeleteClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim开发者_运维百科 selectedRowCount As Integer = Grid.SelectionSettings.SelectedRows.Count
If (Grid.Rows.Count >= selectedRowCount) Then
While Grid.SelectionSettings.SelectedRows.Count > 0
Dim index As Integer = Grid.SelectionSettings.SelectedRows(0).Index
If index >= 0 Then
DeleteRow(index)
End If
End While
End If
End Sub
Private Sub DeleteRow(ByVal rowNumber As Integer)
If Grid.Rows.Count > 0 Then
Grid.Rows(rowNumber).Delete() --->**NotSupportedException: Collection was of a fixed size.**
End If
End Sub
Please help the above code throws me a "Collection was of a fixed size". Would appreciate you help.
I'm assuming that you're using XtraGrid or at least something from DevExpress. According to their forums:
Rows can be added/deleted in the XtraGrid using the AddNewRow and DeleteRow methods only if the bound data source supports the IBindingList interface and implements the corresponding methods of the interface. You can refer to the GridIBindingList tutorial for an example.
What datasource are you using? An array?
精彩评论