收集是固定的大小

时间:2011-08-31 13:09:00

标签: vb.net silverlight

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

请帮助上面的代码告诉我“收藏是固定大小的”。非常感谢你的帮助。

1 个答案:

答案 0 :(得分:1)

我假设您正在使用XtraGrid或者至少使用DevExpress。 According to their forums

  

可以使用AddNewRow和XtraGrid在行中添加/删除行   仅当绑定数据源支持时,才使用DeleteRow方法   IBindingList接口并实现了相应的方法   接口。您可以参考GridIBindingList教程   示例

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

相关问题