This is a migrated thread and some comments may be shown as answers.

Prevent user from using the backspace key to leave value blank

1 Answer 198 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 29 Dec 2011, 06:01 PM
I am using a ComboBox with the following settings:
<Setter Property="TextSearchMode" Value="StartsWith" />
<Setter Property="IsEditable" Value="True" />
<Setter Property="IsReadOnly" Value="True" />

Is there a codeless (MVVM) way to force a valid value to be chosen?  As it stands, the user can click into the "TextBox" part of the RadComboBox, hit the backspace key repeatedly to clear out the text, and effectively set the value to null.  This is even though the ComboBox does not have a null / blank value available for selection via the mouse / arrow keys.

The ideal situation would be to return the ComboBox to its original value if the user does not select a valid value.

I'm sure there is a method of doing this via code behind, but this seems like something that could already be built into the control.

Thank you,
Kevin

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 30 Dec 2011, 02:10 PM
Hello Kevin,

RadComboBox doesn't have any built-in validation. I've attached a simple example which demonstrates how you can implement validation using IDataErrorInfo interface. Please download the attachment and give it a try.

Hope this helps.

Kind regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ComboBox
Asked by
Kevin
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or