I have almost finished with my text editor in Visual basic.. And the last thing I want to add in my project is a sub which will show a Drop-Down menu each time the user adds a letter(character) in the richtextbox..For example when the user types a in the richtextbox, the program will show a Drop-Down menu with all words whose first letter is a.. Then if user types b after a then the Drop-Down menu will have all words whose first two letters are ab..The Drop-Down menu will get its words from a text file in that path: C:/Desktop/txtfile.txt
Asked
Active
Viewed 1,460 times
2
-
2Hopes and dreams are very nice. Unfortunately, they are not valid inputs in SO. Please, try something by your own, share it with us and ask about specific problems. – varocarbas Sep 04 '15 at 07:11
1 Answers
0
You can use TextBox.AutoCompleteMode Property to suggest or append the Predictive text in the textbox or richtextbox.
(source: net-informations.com)
The following VB.Net program add some string values to AutoCompleteStringCollection and display as Autocomplete TextBox while entering text:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.AutoCompleteMode = AutoCompleteMode.Suggest
TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
' You can read the custom source file
' for example: File.ReadAllLine("C://Desktop//txtfile.txt")
Dim DataCollection As New AutoCompleteStringCollection()
addItems(DataCollection)
TextBox1.AutoCompleteCustomSource = DataCollection
End Sub
Public Sub addItems(ByVal col As AutoCompleteStringCollection)
col.Add("Abel")
col.Add("Bing")
col.Add("Catherine")
col.Add("Varghese")
col.Add("John")
col.Add("Kerry")
End Sub
End Class

Glorfindel
- 21,988
- 13
- 81
- 109

Behzad
- 3,502
- 4
- 36
- 63