Sub Find(ByRef Obj As DataGridView, Optional ByVal value As String = Nothing, Optional ByVal cellIndex As Integer = 1)
For Each i As DataGridViewRow In DataGridView1.Rows
If value Is Nothing OrElse value = "" Then
i.Visible = True
Else
Try
If i.Cells(cellIndex).Value IsNot Nothing Then i.Visible = i.Cells(cellIndex).Value = value
Catch ex As Exception
End Try
End If
Next
End Sub
Find(DataGridView1, "张三",1)
那还是这个思路,与数据库没有联系的思路.
1,首先你把这些数据是保存在数组里.
2,单击按钮后,先清除DataGridView里面的内容(会添加,也应该会删除吧?)
3,最后,只添加"张三"的.
数据-在找到相应工具就可