Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a simple invoice application where I need an search option for Item there I have used combobox where when I type "a" It results "apple" which is an default property.But I need "apple" when typing "p" or "l" any ways to do that. Please help me..
Posted
Comments
Maciej Los 15-Oct-14 2:02am    
What have you tried? Where are you stuck?
Sinisa Hajnal 15-Oct-14 2:16am    
Where is your code? There are "like" operators both in .NET strings and various database SQLs...
Moses Geo 15-Oct-14 7:43am    
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load

Dim lst As New List(Of String)

Dim MySource As New AutoCompleteStringCollection()
'Manually added some items
lst.Add("apple")
lst.Add("applle")
lst.Add("appple")
lst.Add("appplee")
lst.Add("bear")
lst.Add("pear")

'Records binded to the AutocompleteStringCollection.
MySource.AddRange(lst.ToArray)

TextBox1.AutoCompleteCustomSource = MySource

TextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend

TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource

End Sub
Moses Geo 15-Oct-14 7:45am    
I need the popup that come for providing suggestion like in this code

1 solution

There is few ways to achieve that.
String.Contains Method[^]
How to: Search Within a String (Visual Basic)[^]

Depending on your needs, you can use special characters, like: *; ?, etc.
If you want to find a in entire string, use:
VB
result = stringVariable Like "*a*"

If you want to find a at the end of string, use:
VB
result = stringVariable Like "*a"

If you want to find a at the beginning of string, use:
VB
result = stringVariable Like "a*"


Please, see:
Like Operator (Visual Basic)[^]
How to: Match a String against a Pattern (Visual Basic)[^]


You can use Regex[^] too.
Converting Wildcards to Regexes[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900