我有一个包含列表项的组合框:
ABC BAC DEE
如何根据输入建议列表。例如,如果用户键入A,则应显示: ABC BAC 因为它们都包含字符串字符A。
答案 0 :(得分:0)
Dim AList As List(Of String) = New List(Of String)
' Iterate through all the items in the combobox.
For Each item As Object In ComboBox1.Items
' If the current item contains A then add to the list.
If item.ToString.Contains("A") Then
AList.Add(item.ToString)
End If
Next
或者你可以通过LINQ来实现,这基本上是相同的:
Dim AList As List(Of String) = New List(Of String)
Dim query = From item In ComboBox1.Items
Where item.ToString.Contains("A")
Select item
For Each item in query
AList.Add(item.ToString)
Next