473,396 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

autocomplete

Hi

I have a simple form, just with one combo box and an OK button - and i have
tried to use the autocomplete routine and I have enabled autocomplete in the
combo box properties.

http://www.java2s.com/Code/CSharp/Co...teComboBox.htm

That is the link that I copied the code from - but the box doesnt
autocomplete and I dont know what i am doing wrong.

Is there another step that I am missing???

Doug
May 16 '07 #1
5 5302
On Wed, 16 May 2007 02:29:35 -0700, Doug <go**********@optusnet.com.au>
wrote:
I have a simple form, just with one combo box and an OK button - and i
have tried to use the autocomplete routine and I have enabled
autocomplete in
the combo box properties.

http://www.java2s.com/Code/CSharp/Co...teComboBox.htm

That is the link that I copied the code from - but the box doesnt
autocomplete and I dont know what i am doing wrong.
I don't really understand your question. The code you refer to in the
link has nothing to do with using the built-in auto-complete attributes of
the .NET ComboBox control.

The code you refer to in the link has a very basic auto-complete. The
AutoCompleteComboBox defined in the example only matches from things
actually in the list of the control. It should do this just fine, without
you having to set any additional properties. Just use that class if the
behavior is what you want.

On the other hand, the built-in auto-complete functionality of the .NET
ComboBox class is more powerful, and also more complicated. Note that at
a minimum, you need to set the AutoCompleteMode property to something
other than None, *and* the AutoCompleteSource to something other than
None. If you want to provide a custom list of things to match against,
you need to use the AutoCompleteCustomSource, as well as setting
AutoCompleteSource to CustomSource.
Is there another step that I am missing???
See above. My guess is that you copied the example code without
understanding what it's doing, and either haven't used the
AutoCompleteComboBox it defines, or you haven't populated the list for the
control so that it has something to match against.

But since you say you also have "enabled autocomplete in the combo box
properties", it sounds like you are *also* trying to use the built-in
functionality at the same time. I think you should probably pick one or
the other and stick with that. If you want to use the built-in
functionality, then just toss out the code example you've referred to and
make sure you've set *all* of the appropriate properties to enable the
built-in functionality to work the way you want.

Pete
May 16 '07 #2
hi Peter

I am still struggling with this. Could you please post some instructions
about how to achieve autocomplete for a combo box?

I have been trying this for about a week and have no joy in my work.

Doug

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Wed, 16 May 2007 02:29:35 -0700, Doug <go**********@optusnet.com.au>
wrote:
>I have a simple form, just with one combo box and an OK button - and i
have tried to use the autocomplete routine and I have enabled
autocomplete in
the combo box properties.

http://www.java2s.com/Code/CSharp/Co...teComboBox.htm

That is the link that I copied the code from - but the box doesnt
autocomplete and I dont know what i am doing wrong.

I don't really understand your question. The code you refer to in the
link has nothing to do with using the built-in auto-complete attributes of
the .NET ComboBox control.

The code you refer to in the link has a very basic auto-complete. The
AutoCompleteComboBox defined in the example only matches from things
actually in the list of the control. It should do this just fine, without
you having to set any additional properties. Just use that class if the
behavior is what you want.

On the other hand, the built-in auto-complete functionality of the .NET
ComboBox class is more powerful, and also more complicated. Note that at
a minimum, you need to set the AutoCompleteMode property to something
other than None, *and* the AutoCompleteSource to something other than
None. If you want to provide a custom list of things to match against,
you need to use the AutoCompleteCustomSource, as well as setting
AutoCompleteSource to CustomSource.
>Is there another step that I am missing???

See above. My guess is that you copied the example code without
understanding what it's doing, and either haven't used the
AutoCompleteComboBox it defines, or you haven't populated the list for the
control so that it has something to match against.

But since you say you also have "enabled autocomplete in the combo box
properties", it sounds like you are *also* trying to use the built-in
functionality at the same time. I think you should probably pick one or
the other and stick with that. If you want to use the built-in
functionality, then just toss out the code example you've referred to and
make sure you've set *all* of the appropriate properties to enable the
built-in functionality to work the way you want.

Pete

May 17 '07 #3
On Thu, 17 May 2007 01:54:23 -0700, Doug <go**********@optusnet.com.au>
wrote:
I am still struggling with this. Could you please post some
instructions about how to achieve autocomplete for a combo box?
Well, depending on what you want to do, you may not need any code (that
you wrote).

The most basic example would be to add the ComboBox to your form in the
designer. Then, in the properties for the ComboBox, find the
AutoCompleteMode, AutoCompleteSource, and AutoCompleteCustomSource
properties. AutoCompleteMode gets set to one of three values: Append,
Suggest, or SuggestAppend. AutoCompleteSource can be set to
CustomSource. And then in AutoCompleteCustomSource, when you put your
mouse over the property value you'll see a little "..." button. Click
that and you can add whatever strings you want the auto-complete
functionality to operate against.

If you want functionality beyond what's provided that way, you'll need to
write code to configure those properties programmatically. But the idea
is the same.

If all you want is an auto-complete that matches against the items already
in the ComboBox's list, then you may find that it is easier to just use
the sample code you referred to. In that case, forget you ever saw the
"AutoComplete..." properties on the built-in ComboBox and just use the
derived control in the sample code you found.

Pete
May 17 '07 #4
Hi Peter

What I am after is some additional functionality for a combo box so that
items that the user has already typed in - in previous sessions of use -
will be suggested in the combo box - but they can choose to ignore those
suggestions - and any new suggestion will be auto-added to those suggestions
for their next use session - similar to the search boxes on google etc.

Thanks for your help so far.

Doug
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Thu, 17 May 2007 01:54:23 -0700, Doug <go**********@optusnet.com.au>
wrote:
>I am still struggling with this. Could you please post some
instructions about how to achieve autocomplete for a combo box?

Well, depending on what you want to do, you may not need any code (that
you wrote).

The most basic example would be to add the ComboBox to your form in the
designer. Then, in the properties for the ComboBox, find the
AutoCompleteMode, AutoCompleteSource, and AutoCompleteCustomSource
properties. AutoCompleteMode gets set to one of three values: Append,
Suggest, or SuggestAppend. AutoCompleteSource can be set to
CustomSource. And then in AutoCompleteCustomSource, when you put your
mouse over the property value you'll see a little "..." button. Click
that and you can add whatever strings you want the auto-complete
functionality to operate against.

If you want functionality beyond what's provided that way, you'll need to
write code to configure those properties programmatically. But the idea
is the same.

If all you want is an auto-complete that matches against the items already
in the ComboBox's list, then you may find that it is easier to just use
the sample code you referred to. In that case, forget you ever saw the
"AutoComplete..." properties on the built-in ComboBox and just use the
derived control in the sample code you found.

Pete

May 17 '07 #5
On Thu, 17 May 2007 13:36:06 -0700, Doug <go**********@optusnet.com.au>
wrote:
What I am after is some additional functionality for a combo box so that
items that the user has already typed in - in previous sessions of use -
will be suggested in the combo box - but they can choose to ignore those
suggestions - and any new suggestion will be auto-added to those
suggestions
for their next use session - similar to the search boxes on google etc.
I recommend, then, that you maintain a list of those entries in a
StringCollection. Save them to the user's settings (use the project's
Properties.Settings.Default property to store them), and use that
collection to initialize the combo box's AutoCompleteCustomSource property
any time you use the combo box.

Hook an event handler to the Validate event of the combo box, and every
time the combo box gets validated, add the newest entry to that
StringCollection. If you want to limit the size of the StringCollection
(not a bad idea :) ), you can do something like removing the string from
the StringCollection and reinserting it either at the end or the beginning
of the collection, when you are adding a string to the collection (you'll
want to look for the string in any case, so to avoid wasteful duplicates),
and then if the collection gets larger than some maximum size you pick
(50, 500, whatever) remove an item from the opposite end (that is, if new
items get added to the beginning, remove an item from the end to make room
once you've reached your maximum size).

Note that for some common types of information (URLs, filenames, etc.) the
combo box already supports them automatically. The above is something
you'd use if you are saving types of information that don't fall into the
existing categories supported by AutoCompleteSource (see the docs for the
full list).

Pete
May 18 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bc | last post by:
Hi, Is it possible to detect if the IE autocomplete function in a current context such as a textbox is activated (ie. dropdown with previously entered info is visible)? Problem: I use a script...
40
by: Alex | last post by:
Hello, does anybody know how to turn off the autocomplete feature for a certain text field? I am aware of the "autocomplete" attribute, but I have seen other implementions achieving it...
0
by: Thorsten Ottosen | last post by:
Hi, I'm using the AutoComplete attribute to control transactions. What happens if I call functions with the AutoComplete attribute from within other functions with the AutoComplete attribute?...
8
by: moondaddy | last post by:
I have a form for entering a user's address and all fields have a required validating control associated with them and the error msg for each field displays right next to it. The normal behavior...
2
by: Mrinal Kamboj | last post by:
Hi , Need to get some basic info regarding AutoComplete Attribute in COM+ . I am having a class with TransactionOption set to Required , now for this class , can i mark all the methods with...
1
by: thubba2000 | last post by:
We have a web application developed using IBuySpy. In older versions, Autocomplete on all web forms works. In our latest version, it stopped working on all clients. I have gone through all the...
1
by: rbg.net | last post by:
I know that there is a autocomplete property for the HTML "INPUT type=text" control which if set to OFF, disables autocomplete of the input textbox (doesn't remember previously entered values) ...
8
by: nil | last post by:
Hello all, It's urgent... i want to add autocomplete textbox facility in my application like google. as you type it suggests option to the user..i want the same kind of facility...i know i...
1
by: wkerplunk | last post by:
Below is what I have build with several different languages. It works great but I need help, I am stuck. When you click on an item in the dropdown autocomplete div it does a mousedown function...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.