关于DataGridView1数据绑定后查找问题
Dim mydataset As New DataSetDim rs_raw As String = "select aa,bb from A1 order by aa"
Dim da As New SqlClient.SqlDataAdapter
da.SelectCommand = New SqlClient.SqlCommand(rs_raw, conn)
da.Fill(mydataset)
DataGridView1.DataSource = mydataset.Tables(0)
我想查找DataGridView1第一列数据里某个字符或前字符,请问怎样找法。
Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
Dim i As Integer
Dim aa As Integer = Len(TextBox2.Text)
For i = 0 To DataGridView1.Rows.Count - 1
If Len(DataGridView1.Rows(i).Cells(0).Value) > aa Then
If Mid(DataGridView1.Rows(i).Cells(0).Value, 1, aa) = Mid(TextBox2.Text, 1, aa) Then
DataGridView1.CurrentCell = DataGridView1.Rows(i).Cells(0)
Exit Sub
End If
End If
Next
End Sub
上面的找法,如果数据有3万条以上就会很慢,我想用有关mydataset.Tables(0)的查找,怎样可以实现呢?