For the first TextBox txtName, it is showing a dropdown list but for the other TextBox i am not getting any dropdownlist
Below code is of .net windows form app showing 2 TextBoxes with drop down suggestion when user types something in it. the code for first TextBox txtName is working but the other one is not....i need hellp on this.
To say that one of these is working and the other is not leads me to believe that you have set up something in the gui properties because I see nowhere where you set this stringcollection to your autocompletecustomsource. That being said, let's use 2 new textboxes and set up a demo that you can test on your own machine.
For the building of the AutoCompleteStringCollection, I'm going to just use a list but you would use your query. I will try to denote where you would use those methods.
Since you're using the same data for both textboxes, we only need to create the collection once. We'll do this in the form load.
Notice that this code is not in any of the textbox events. Especially the TextChanged event as that would run with every change to the textbox and we don't need to do that as we only need to fill the collection and assign it to the textbox(s) that we want to use the collection with before we need to use the dropdown.
Again, if you run this demo, I strongly suggest you add two new textboxes named as I have them named because I really feel you've done something outside of writing code to get the first one to work.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.