【发布时间】:2013-03-21 16:10:01
【问题描述】:
我正在尝试在 datagridview 中进行搜索,遍历每个单元格并比较 2 个字符串 - SearchString 和 CellString。
我将工作分成四个并行工作的线程(通过为每个线程分配不同的四分之一行来处理)。线程不能同时读取同一个单元格,因为它们循环遍历不同的行,所以我认为不存在错误。
每个线程执行以下操作:
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 上执行搜索吗?
标签: vb.net datagridview bindingsource