AutoCompleteBox Clearing SelectedItem

3 posts, 0 answers
  1. Prashu
    Prashu avatar
    17 posts
    Member since:
    May 2013

    Posted 20 Sep 2013 Link to this post

    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. Rosen Vladimirov
    Admin
    Rosen Vladimirov avatar
    640 posts

    Posted 20 Sep 2013 Link to this post

    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 >>
  3. DevCraft banner
  4. Gustavo Ruzzante
    Gustavo Ruzzante avatar
    1 posts
    Member since:
    Dec 2009

    Posted 03 Feb in reply to Prashu Link to this post

    try this:

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

     

     

Back to Top