Forums → Programming Forum → Visual Basic 2005 - Textbox Guessing Feature
14 | 5547 |
Hello everyone
I was making something in VB and I thought that if I added a word completion/guessing feature to toolboxes it would be neat. If you don't understand what I mean by word completion/guessing, go to Google.com and type something in the search bar. When you start to type your word, a list pops up underneath and gives you suggestions.
That is what I want to make...except, I am totally stumped >.<
Would I need a text box so that the user can type in it and a visibility changing list box underneath it? Except, how would I make the suggestions appear in it?...
BTW, all the possible suggestions the list box can use are in a database.
I will greatly appreciate it if anyone can help me
- 14 Replies
Yeay! VB! That's more like it.
I'll load up Visual Studio and try around a bit to see if I can get something working. I will return...
And by database I'm guessing you mean a local MS SQL database, right?
Are you familiar with how to load data from a database, or should I help you with that as well?
Okay. Found it. At first I was going to try to create a new component myself, but luckily it was already available.
In the Properties window, under the Misc category (if you have the properties categorized) there are 3 properties.
AutoCompleteCustomSource (The list of items that should be suggested to the user)
AutoCompleteMode (This should either be Suggest, or SuggestAppend, depending on which one you prefer)
AutoCompleteSource (This should be CustomSource)
You can either automatically data bind the values for the textbox from the database, or you can write code that adds the values to the CustomSource list when the form loads.
Also, you could even make the text box a drop down box and let the users see all the values that will autocomplete.
If you need any more help, just ask. I can even send you the source as an example of what should be dome.
Yay another VB programmer...
Thank you very much...you just made a newbie programmer's day...feel special
I will try what you said soon. And also, if you don't mind, can you send the source? Its just so that I don't have to bug you anymore if something goes wrong.
Also, you could even make the text box a drop down box and let the users see all the values that will autocomplete.
I'm pretty sure I won't be doing that...there are 3000 values in total XD
Thank you again
Sorry for the double post, but I have a problem...
The CustomSource is messing up when I set its databinding to the thing I want.
The properties are as follows:
customsource to databinding
I set autocompletion to suggest
completesource to custom source
It works if I just type in the values as a string, but when I connect it to the database, it doesn't do anything.
While compiling, if I click in the textbox and start typing, nothing shows up, and further more, once I click in the textbox, I can't seem to close the program or change the focus by clicking elsewhere...its not not responding...
Any ideas why its like this?...
Are you able to DataBind your database to other components, such as a list box?
Are you trying to connect to a local MS SQL database, or a remote database?
If you send me the source code, I might be able to get it to work.
Anything sent to me is 100% confidential, and the source code will not be distributed elsewhere or claimed as my own.
While compiling, if I click in the textbox and start typing, nothing shows up, and further more, once I click in the textbox, I can't seem to close the program or change the focus by clicking elsewhere...its not not responding...
My guess is that the app is having trouble connecting to the database. How long does it stay unresponsive? After a while, the timeout on the database
Did it run just fine before you databound the text field?
Or how long is your list? If the database is loading an entire dictionary, it might take a while. You might want a loading screen and set the entire form's enabled to false and then reenable it when the entire database is loaded.
I can send you some sample code of how I did that for my Random Drug Testing program. (It doesn't actually drug test, it just selects students randomly from a SQL database for testing, and is currently being used by the local schools)
Yes databind works on other things...I'd already double checked it
I am trying to connect to a Database made on Access that is in my hard drive...so yes, an SQL database...
I trust you
I will send you the file including the database as soon as I manage to upload it
whoops...didn't see your last post...
From what I've seen, it stays unresponsive for ever...although note that Windows task manager said the program was 'Running'
Before databinding it worked fine. It also works fine when I manually type in the values.
My list, currently is only 4 records...after I'm done the program, the database will be changed to a 2000 record one. I thought it was 3000, but I rechecked and it is 2000 now...
And, I wouldn't mind the sample program
Aww I remember the days when I first started using VB 6.0 -- now I shudder at the thought that businesses still rely on that horribly maintained language...
haYnguy, have you tried the new VB.net 2005? (or whatever newer version is out now)
Significant improvements! I wish it were cross platform, though.
I just downloaded Visual Basic Studio for my comp and if someone could post simple practices to get me used to the features and syntax that would be much appreciated.
I'm looking at you IqAndreas
The Microsoft Developer Network has a lot of goodies:
http://msdn.microsoft.com/en-us/default.aspx
Several Visual Basic tutorials:
http://msdn.microsoft.com/en-us/vbasic/cc817878.aspx
And since I like learning from videos the most:
http://msdn.microsoft.com/en-us/vstudio/aa700732.aspx#beginners
That is my absolute favorite set of videos, and how I learnt VB for the first time many years ago. They have been updated since to reflect the new version of VB.net.
Enjoy
You must be logged in to post a reply!