How to restrict user from entering text which is not in a display member of combobox items

raj

How to restrict user from entering text which is not in a display member of combobox items.

scenario:

i have set the following properties:

AutoCompleteMode = SuggestAppend
DropdownStyle = DropDown

now combobox is editable, when i enter text it's suggesting few items which starts with the text which i have entered.
but i don't want to let my user to enter text other than the text that control suggests.

how can i restrict? Is there any direct property or have to write any code?

The result is: start typing so that the autocomplete finds a match in the combo items collection, then continue typing something that differs from that item and press Enter - you will end up with the item found by the autocomplete.

The second workaround was proposed by a customer. It works fine, except for the case when you use the Backspace or Key arrows, which will lead to undesired results. Just put the following code in the KeyUp event handler:

Alex Peachey

I'd like to do this as well but I find that it does not look like the RadComboBox control has a TextChanging event. I think that would be the cleanest solution barring built-in functionality, but it is not viable without that cancel-able event.

I'll go ahead and try the customer submitted solution but I don't like the fact that it breaks down with the use of special keys.

Alex Peachey

Thank you Nikolay. I should have read that better. I got excited as I saw what appeared to be the solution to something I was trying to do and basically just read the post and didn't really look at your provided code. I ran off to go handle the TextChanging event and couldn't find it.

Now that I actually re-read the answer and the provided code I see exactly what you are doing and I believe that will work for what I need until the functionality is built in.

Nikolay

Indeed, this is the current behavior of RadComboBox in the regarded scenario. In order to achieve your goals, you should clear the text in TextChanged, but not in TextChanging event handler. I am attaching a sample project to demonstrate how this should be done. To test the example, please first type "Ar" for Argentina, then press the Q key to clear the field, then Enter and finally the Z key to test whether the field will be cleared again.

I hope this helps. If you have additional questions, feel free to contact me.

Greetings,
Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.

Ifdev02

Not sure how long this post was but the winform still doesnt have the custom text disable mode for combobox which is quite standard for this type of control. ...
What could be the replacement control if i want to use simple selector box, that shown selected item?

Nikolay

If you regards the general user ability to type text, RadComboBox supports a mode where the user is not allowed to type in the editor part. For additional information, please refer to the following article: DropDownStyle.

This forum thread concerns a custom scenario where the user is able to type only the text which is a part of the an existing RadComboBox item.

I hope that this information is helpful. If you have additional questions, feel free to contact me.

Best wishes,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

Nikolay

Currently, we have an issue with canceling the TextChanging event of RadComboBoxElement. Until the issue is addressed, please subscribe to the TextChanging event of MyComboBoxElement.TextBoxElement.TextBoxItem.

If you have additional questions, feel free to contact me.

All the best,
Nikolay
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

Andrea

And now with Q3 2012 SP1 how i can do the same thing? With Dropdownlist, using Autocompletemode = SuggestAppened and Dropdownstyle = Dropdown. I want do the same that i can see in the Telerik Demo Application (DropDown & List > DropDownList > Auto complete example).
Thanks for reply.

George

What you are talking about is an issue in RadDropDownList. This issue has been resolved in our latest release. You can either upgrade to the latest version or use the following workaround: subscribe to the KeyUp event of RadDropDownList ​and use the following code:

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.