2011-08-31 2 views
0
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

저는 XtraGrid 또는 적어도 DevExpress의 것을 사용하고 있다고 가정합니다. According to their forums :

행이 추가 될 수/바인딩 된 데이터 소스는 IBindingList 인터페이스를 지원하고 인터페이스의 대응 방법을 구현하는 경우에만 AddNewRow 및 deleteRow를 방법을 사용 XtraGrid 삭제. 예제에 대한 GridIBindingList 자습서를 참조 할 수 있습니다.

어떤 데이터 소스를 사용하고 있습니까? 배열?

관련 문제