我的表单允许用户搜索一组客户。当我单击“搜索”按钮时,我希望它仅显示找到的特定结果并隐藏其他客户。
例如,如果我将客户ID设置为133
,则应仅显示该客户ID并隐藏其余的客户。
Private Sub SearchButton_Click(sender As Object, e As EventArgs) Handles SearchButton.Click
Dim foundIndex As Integer
Dim searchString As String
searchString = SearchTextBox.Text
foundIndex = CustomerRecBindingSource.Find("customerid", searchString)
If foundIndex > -1 Then
DataRepeater1.CurrentItemIndex = foundIndex
Else
MsgBox("Item " & searchString & " not found.")
End If
End Sub
此版本仅将搜索结果置于顶部。它不会隐藏其余数据。
我尝试更改行:
DataRepeater1.CurrentItemIndex = foundIndex
到
DataRepeater1.CurrentItem = foundIndex
但是我得到了错误Property 'Current Item' is 'Read Only'