Prevent user from using the backspace key to leave value blank

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    27 posts
    Member since:
    Aug 2012

    Posted 29 Dec 2011 Link to this post

    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,
  2. Yana
    Yana avatar
    4604 posts

    Posted 30 Dec 2011 Link to this post

    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,
    the Telerik team

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

Back to Top