Connecting Tech Pros Worldwide Help | Site Map

Display the combo box items

Newbie
 
Join Date: Mar 2009
Posts: 10
#1: Mar 20 '09
I have a combobox with a list of items in it. Now when the user enters a character I want the combox show the list of items that starts with the specified character. Could someone please help me solve this problem.

Thanks in Advance
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,739
#2: Mar 20 '09

re: Display the combo box items


Please show us what you have tried so far, so we can better help you with where your code is going wrong.
Member
 
Join Date: Jul 2007
Posts: 87
#3: Mar 20 '09

re: Display the combo box items


i think i understand what you are trying to do, Your trying to search for each item within the combo box that contains the letters that are typed in to the combo box,

Where abouts are you getting the items from? A database?

If so you could just make a simple sql statement and everytime the textchanged event is launched fire up the sql

another way would be to have a list of your items on the text changed event
clear all the current items out of the combo
start a for loop to go through the list
if the item in that list contains whatever has been typed in so combo1.text
add it to the items of the combo
Newbie
 
Join Date: Mar 2009
Posts: 10
#4: Mar 20 '09

re: Display the combo box items


Quote:

Originally Posted by truezplaya View Post

i think i understand what you are trying to do, Your trying to search for each item within the combo box that contains the letters that are typed in to the combo box,

Where abouts are you getting the items from? A database?

If so you could just make a simple sql statement and everytime the textchanged event is launched fire up the sql

another way would be to have a list of your items on the text changed event
clear all the current items out of the combo
start a for loop to go through the list
if the item in that list contains whatever has been typed in so combo1.text
add it to the items of the combo

Thanks for your suggestion
Member
 
Join Date: Mar 2009
Location: Kathmandu
Posts: 42
#5: Mar 20 '09

re: Display the combo box items


One more information, textbox and combobox support autocomple feature, look at their property, you might be intersted in combobox with autocomplete source set to listitems, and autocomplete mode to SuggestAppend or Append or anything like that
Newbie
 
Join Date: Mar 2009
Posts: 10
#6: Mar 24 '09

re: Display the combo box items


Quote:

Originally Posted by aryanbs View Post

One more information, textbox and combobox support autocomple feature, look at their property, you might be intersted in combobox with autocomplete source set to listitems, and autocomplete mode to SuggestAppend or Append or anything like that

Thanks for your Suggestion
I have set the AutoCompleteSource and AutoCompleteMode properties of the combox. Now it displays the dropdown list and allows me to
select the item from the list but is not allowing to enter a new item to the combobox text field.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cbcity_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbcity.TextChanged
  2.         If cbcity.Text <> "" Then
  3.             cbcity.AutoCompleteSource = AutoCompleteSource.ListItems
  4.             cbcity.AutoCompleteMode = AutoCompleteMode.SuggestAppend
  5.         End If
  6.     End Sub
  7.  
Please tell me where I have made the mistake
Member
 
Join Date: Mar 2009
Location: Kathmandu
Posts: 42
#7: Mar 25 '09

re: Display the combo box items


Dont use textchanged event, just use those code in the beginning or after binding the data
combobox.DataSource= YouDataSource

and those 2 lines after that
Newbie
 
Join Date: Mar 2009
Posts: 10
#8: Mar 26 '09

re: Display the combo box items


Quote:

Originally Posted by aryanbs View Post

Dont use textchanged event, just use those code in the beginning or after binding the data
combobox.DataSource= YouDataSource

and those 2 lines after that

Thanks. Now its working fine
Reply