【发布时间】:2013-12-27 11:23:36
【问题描述】:
我有一个 DataGridView,在保存数据之前,我想检查特定列是否在任何行中有任何重复值。
If DataGridView1.Rows.Count > 2 Then
Dim count As Integer = 0
Dim i As Integer = 0
While DataGridView1.Rows.Count - 1
Dim j As Integer = 1
While DataGridView1.Rows.Count - 1
Dim str As String = DataGridView1.Rows(i).Cells("ColLedger").Value()
Dim str1 As String = DataGridView1.Rows(j).Cells("ColLedger").Value()
If str1 = str Then
count = count + 1
End If
j += 1
End While
i += 1
End While
If count > 0 Then
MsgBox(count)
End If
我收到索引超出范围错误。我不确定我做错了什么。
如果可以使用在线工具轻松转换,我也会接受 c# 答案。
【问题讨论】:
标签: c# .net vb.net datagridview