For example, when I start typing “app”, it should display all the words in the suggestion list starting with app. When I enter a word and press the space bar and start typing When a new word is new, it should display all the suggestions for that part of the word.
Is there an example I can look at?
Private Sub txtToEmail_EditValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtToEmail.EditValueChanged
Try
Dim Emails As New List(Of String)
Emails.Add("[email protected]")
Emails.Add("[email protected]")
Emails.Add("[email protected]")
Emails.Add("[email protected]")
Dim Txt = Trim(CStr(txtToEmail.EditValue))
Dim Suggestions As IEnumerable(Of String)
If Txt <> "" Then
If Txt.IndexOf(",") = -1 Then
Suggestions = From c In Emails Where c.StartsWith(Txt) Select c
Else
Dim lastIndex = Txt.LastIndexOf(",")
Dim lastWord = Trim(Txt.Substring(lastIndex + 1))
Suggestions = From c In Emails Where c.StartsWith (lastWord) Select c
End If
EmailList.Items.Clear()
For Each r In Suggestions
EmailList.Items.Add(r )
Next
End If
If EmailList.ItemCount> 0 Then
EmailList.Visible = True
End If
Catch ex As Exception
ShowErrorBox(ex)
End Try
End Sub
Private Sub EmailList_Click(ByVal sender As System.Object , ByVal e As System.EventArgs) Handles EmailList.Click
Try
If EmailList.SelectedValue = Nothing OrElse EmailList.SelectedValue = "" Then Return
Dim Txt = CStr(txtToEmail .EditValue)
If Txt.IndexOf(",") = -1 Then
txtToEmail.EditValue = EmailList.SelectedValue
Else
Dim lastIndex = Txt.LastIndexOf (",")
txtToEmail.EditValue = Txt.Substring(0, lastIndex + 1) & Ema ilList.SelectedValue
End If
txtToEmail.Focus()
txtToEmail.SelectionStart = CStr(txtToEmail.EditValue).Length
EmailList.Visible = False
Catch ex As Exception
ShowErrorBox(ex)
End Try
End Sub
I am Develop an application that requires a text box with auto-completion/suggestions (drop-down) for multiple words (separated by space separators), just like the label text box in StackOverflow.
For example, I start typing “app”, it should display all the words in the suggestion list starting with app, when I enter a word and press the space bar and start typing a new word, it should display all the suggestions for that part of the word .
Is there an example I can look at?
I hope this helps.. I use the Developer Quick Tool, but it can also be used with regular .net components.
p>
Private Sub txtToEmail_EditValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtToEmail.EditValueChanged
Try
Dim Emails As New List(Of String)
Emails.Add("[email protected]")
Emails.Add("[email protected]")
Emails.Add("[email protected]")
Emails.Add("[email protected]")
Dim Txt = Trim(CStr(txtToEmail.EditValue))
Dim Suggestions As IEnumerable(Of String)
If Txt <> "" Then
If Txt.IndexOf(",") = -1 Then
Suggestions = From c In Emails Where c.StartsWith(Txt ) Select c
Else
Dim lastIndex = Txt.LastIndexOf(",")
Dim lastWord = Trim(Txt.Substring(lastIndex + 1))
Suggestions = From c In Emails Where c.StartsWith(lastWord) Select c
End If
EmailList.Items.Clear()
For Each r In Suggestions
EmailList.Items.Add(r)
Next
End If< br />
If EmailList.ItemCount> 0 Then
EmailList.Visible = True
End If
Catch ex As Exception
ShowErrorBox(ex)< br /> End Try
End Sub
Private Sub EmailList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EmailList.Click
Try
If EmailList.SelectedValue = Nothing OrElse EmailList.SelectedValue = "" Then Return
Dim Txt = CStr(txtToEmail.EditValue)
If Txt.IndexOf(" ,") = -1 Then
txtToEmail.EditValue = EmailList.SelectedValue
Else
Dim lastIndex = Txt.LastIndexOf(",")
txtToEmail.EditValue = Txt.Substring( 0, lastIndex + 1) & EmailList.SelectedValue
End If
txtToEmail.Focus()
txtToEmail.SelectionStart = CStr(txtToEmail.EditValue).Length
EmailList.Visible = False
Catch ex As Exception
ShowErrorBox(ex)
End Try
End Sub