RadCombobox: prevent “Backspace” button from clearing selected item.

2 posts, 0 answers
  1. Andrii
    Andrii avatar
    1 posts
    Member since:
    Jul 2011

    Posted 10 Feb 2012 Link to this post

    It seems that default behavior of RadCombobox is to clear selected item when control is focused, some item is selected  and “Backspace” button is pressed. 

    I need to cancel this behavior in order to prevent setting of null as the selected combobox value. I tried to override KeyDown and KeyUp methods of RadCombobox and handle the click on “Backspace” but it did not fix the problem.

    Are there any other ways to change this keyboard behavior?



  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 15 Feb 2012 Link to this post

    Hello Andrii,

    Try the following code to prevent "Backspace" button from clearing the text.
    public MainPage()
       RadComboBox1.AddHandler(KeyDownEvent, new KeyEventHandler(RadComboBox1_KeyDown), true);
       string combotxt;
       private void RadComboBox1_KeyDown(object sender, KeyEventArgs e)
                 if (RadComboBox1.SelectedItem == null)
                       RadComboBox1.EmptyText = combotxt;
            private void RadComboBox1_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)
                combotxt = RadComboBox1.Text;

Back to Top