我試圖在datagridview中進行搜索,循環遍歷每個單元格並比較兩個字符串 - SearchString和CellString。VB.NET BindingSource不能是它自己的數據源... datagridview中的錯誤
我把工作分成四個線程(通過給每個線程一個不同的四行處理器)並行工作。線程不能同時讀取同一個單元,因爲它們循環通過不同的行,所以我不認爲這個錯誤在那裏。
每個線程執行以下操作:
dim CellString as string
For i As Integer = startrow To endrow
For Each cell As DataGridViewCell In DataGridView.Rows(i).Cells
CellString = cell.Value.ToString.ToLower ''Error appears here
If cell.ColumnIndex <> 4 Then
Select Case Compare(CellString, SearchString) ''complex function that compares 2 strings
''....
End Select
End If
Next
Next
我得到的錯誤是:
的BindingSource不能是自己的數據源。不要將DataSource和DataMember屬性設置爲引用BindingSource的值。
我不明白爲什麼會發生這種情況,因爲我不會弄亂BindingSource和DataSource。此外,我不做任何更新,我只讀取每個單元格作爲字符串。
我找不到任何類似的問題,所以任何幫助表示讚賞!
你不能在數據源本身而不是DGV上執行搜索嗎? – rheitzman 2013-08-09 17:22:52