收藏是一个固定的大小

问题描述:

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 

请帮助上面的代码抛出我一个“集合是一个固定的大小”。将不胜感激你的帮助。收藏是一个固定的大小

我假设你使用的是XtraGrid或者至少是DevExpress的东西。 According to their forums

行可以被添加/使用AddNewRow和 DeleteRow方法只有在绑定数据源支持 IBindingList的接口和实现 接口的相应的方法在XtraGrid中删除。您可以参考GridIBindingList教程获取 示例。

您使用的是什么数据源?数组?