Link to home
Start Free TrialLog in
Avatar of George
GeorgeFlag for Canada

asked on

how to limit combobox to items in the list

Hi Everyone,

In a VB.NET 2005 windows application

In a combobox, I need to reject the entry if the user type/pick something different that the list.

How can I limit the user to input only items form the list?

TIA

Jorge

Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

You can change the DropDownStyle to DropDownList
Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList

Open in new window

Avatar of George

ASKER

Hi JPaulino

Thank you for your response,

For some reason is not preventing form inputting any value that I want, despite that the property  DropDownStyle is selected to  DropDownList

Is there any other setting that I have to adjust?

TIA
You can use the keys to jump to some item but you cannot write a new one, right ?
Avatar of George

ASKER

Ok I placed the

Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList

in the event Enter of the DropDown and now is working .... , but The problem is that I need the autocomplete....
   
     cmbCommunity.AutoCompleteMode = AutoCompleteMode.SuggestAppend
     cmbCommunity.AutoCompleteSource = AutoCompleteSource.ListItems

Is there a way to have both functionalites ? limit to list and aswell autocomplete?

TIA
How do you define the itens for the combobox ?
ASKER CERTIFIED SOLUTION
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of George

ASKER

Thank you very much, the examples gave the ideas on how to make it work.