list of values and textbox

uls123

Member
Joined
Mar 14, 2013
Messages
7
Programming Experience
Beginner
Hello my friends,

when clicking inside a textbox, how can i display a list of values from a table created in sql and selecting one of them to appear in that textbox?

thank you in advance.
 
Create an AutoCompleteStringCollection
Use the Add method of your newly created list to populate it.

Set your textbox's AutoCompleteCustomSource to your list
set your textbox's AutocompleteMode to your preference (ie, Suggest, SuggestAppend, ect)
Set your textbox's AutoCompleteSource to AutoCompleteSource.CustomSource

Now when you type, it should drop down a list
 
What i want is not the auto complete option but instead the textbox is empty and even though i don't type anything; when i click inside it, it shows me the list of values.
I would have chosen the combo box, but i want to do something new this time :)
 
Populate a list, set its .Visible property to false in the textbox's Leave event set it's .Visible property to true in the textbox's Enter event.

Write code to place the selected item in the list box inside the textbox.
 
I would have chosen the combo box, but i want to do something new this time :)
I know what you mean. I needed to get somewhere yesterday and I know they make cars for transport but I decided to ride my fridge instead.
 
The ComboBox control is designed for one purpose and the TextBox for another. If what you want to achieve matches the purpose the ComboBox was designed fro then you should use a ComboBox. If you want something in programming to challenge you then there are far more useful things you could be doing than trying to use a TextBox where a ComboBox is more appropriate.
 
Back
Top