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

AutoCompleteBox Clearing SelectedItem

2 Answers 338 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Prashu
Top achievements
Rank 1
Prashu asked on 20 Sep 2013, 05:53 AM
How to Clear a SelectedItem of  AutoCompleteBox  using C#  i'm using this it's working for all controls except autocompletebox

 void clear()
        {
            //This loop takes all controls from the form1 - make sure your form name as newInvoice otherwise change it as per your form name

            foreach (var controls in newReceiveItemView.GeneralGridLayout.Children)
            {
                //Clear all textbox values
                if (controls is TextBox)
                    ((TextBox)controls).Text = "";

                //clear all check boxes
                if (controls is CheckBox)
                    ((CheckBox)controls).IsChecked = false;

                //Clear all RadComboBox 
                if (controls is RadComboBox)
                    ((RadComboBox)controls).SelectedItem = null;

                //Clear all RadAutoCompleteBox 
                if (controls is RadAutoCompleteBox)
                    ((RadAutoCompleteBox)controls).SelectedItem = null;// this is not working selectedItem is not Clearing
                
                //((RadComboBox)controls).SelectedIndex = -1;

                //Clear all radio buttons
                if (controls is RadMaskedTextBox)
                    ((RadMaskedTextBox)controls).Value = "";
}
}

2 Answers, 1 is accepted

Sort by
0
Rosen Vladimirov
Telerik team
answered on 20 Sep 2013, 02:53 PM
Hello Prashu,

You should set SelectedItems property to null in order to clear the selection:
this.AutoComplete.SelectedItems = null;

Hope this helps.

Regards,
Rosen Vladimirov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Gustavo Ruzzante
Top achievements
Rank 1
answered on 03 Feb 2016, 01:23 PM

try this:

 ((RadAutoCompleteBox)controls).Entries.Clear(); 

 

 

Tags
AutoCompleteBox
Asked by
Prashu
Top achievements
Rank 1
Answers by
Rosen Vladimirov
Telerik team
Gustavo Ruzzante
Top achievements
Rank 1
Share this question
or