Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Como box

Status
Not open for further replies.

kss444

Programmer
Sep 19, 2006
306
US
I have a combo box on my form (written in c#). I want to populate this combo from a stored proc. (easy enough) but I only want to have the combo populated once the user has typed at least one charactor in the combo. I will use this value as a param to my stored proc. to return limited results.

I am not sure where to put this coded. Should I put it in the _SelectedIndexChanged or elsewhere.

Thanks,
kss

Ordinary Programmer
 
what you are describing is autocomplete. being i web developer we use a textbox for the free text and DHTML to create the look of a dropdown.

Not sure how this is done for a desktop UI. However I do not think selectedindexchanged is the correct event. after all you are not changing the index, you are typing text. If the dropdown allows for free text and has a textchanged, or keypressed/up event then this would be the event I use to load the dropdownlist.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
I too am primarily a web developer, but now at this new company I have to also be a client server desktop app developer also.

Ordinary Programmer
 
Its likely just as efficient, (in terms of time spent), and more friendly to populate the list items at load time and utilise the AutoCompleteMode and AutoCompleteSource properties of the combo box. How many items are likely to be populated?

Rhys

"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
Terry Pratchett
 
@Rhys
what if the query returns hundreds or thousands of items? it would be far more efficient to query the source as the user enters text, than it would to pre-load the data.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
If the query returns hundreds or thousands of items, is a combo box an appropriate control in which to display/select them, and is there something wrong in the design/implementation in use?

If your users type at a reasonable rate what sort of response can you expect from your datasource for autocompletion?

Would it actually be better to provide an initial A-Z filter, and then populate your combobox based on this as your initial letter?

If there are really so many values that you can't put all of them comfortably in a combobox, I'd find another way to do it.

Rhys

"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
Terry Pratchett
 
I would not expect more than 10 rows being returned. It is a dropdown that contains customer account info. (acct, jasc) codes that look like that.

So I don't want all customer codes to be in the drop down, I just want all the j's if typed or a's if they type an a.

It will never be 1000's.

Ordinary Programmer
 
not necessarily. take Google's search box for example. it acts as an auto-complete but you know it's not loading all the search terms in the drop down when the page initially loads. it waits for the user to begin typing and returns appropriate results.

as for getting the result back in a timely manner. there are a variety of methods to reduce latency, but that is a separate concern then how to populate the auto-complete.

Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
faq732-7259
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top