No way to clear multiple selections

8 posts, 1 answers
  1. Alex
    Alex avatar
    3 posts
    Member since:
    Jan 2012

    Posted 08 Jan 2013 Link to this post

    I can't find a way to clear selected items when RadAutoCompleteBox SelectionMode is set to "Multiple". I don't want to re-instantiate a new one just to clear selections.
  2. Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 08 Jan 2013 Link to this post

    Hi Alex,

    I believe that casting the SelectedItems to IList and calling the Clear() method will help you.
    var list = this.AutoComplete.SelectedItems as IList;
    if (list != null)
    {
        list.Clear();
    }

    All the best,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Alex
    Alex avatar
    3 posts
    Member since:
    Jan 2012

    Posted 09 Jan 2013 Link to this post

    What about the visual representation of clearing the selections from the control? It's not happening. How to programmatically remove or add items to the control and have the control reflect the changes? Why can't it behave more like a ListBox in that aspect where you can do things like listBox1.SelectionItems.Add(item)? 

    RadAutoCompleteBox just doesn't feel like a completely functional control like it should.
  4. Answer
    Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 11 Jan 2013 Link to this post

    Hi Alex,

    I tried this and it worked as expected. You can find my sample project attached. It would be great if you modify it to demonstrate the issue and send it back to us so we will be able to investigate it further. We will also consider changing the Selecteditems' interface from IEnumerable to IList.

    Greetings,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Alex
    Alex avatar
    3 posts
    Member since:
    Jan 2012

    Posted 11 Jan 2013 Link to this post

    I found that I didn't have the latest RadControls. After upgrading to the latest, this issue went away. But yes, it would be better if one doesn't need to cast SelectedItems to IList in order to perform clear, add, remove item operations. Thanks for looking into this.
  6. Sreelaskshmi
    Sreelaskshmi avatar
    6 posts
    Member since:
    Aug 2014

    Posted 07 Sep in reply to Ivo Link to this post

    HI Ivo,

    In my case ,user want to select all selected items(4016,4011 please refer attachment) by pressing the ctrl+A & press delete to clear the items.

    Please let me know ,How to implement this requirement. 

    Thanks,

    Mohan G

  7. Dinko
    Admin
    Dinko avatar
    444 posts

    Posted 12 Sep Link to this post

    Hello Sreelaskshmi,

    We will check your scenario and contact you again as soon as we have more information about your case.

    Thank you for your patience.

    Regards,
    Dinko
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  8. Dinko
    Admin
    Dinko avatar
    444 posts

    Posted 12 Sep Link to this post

    Hello Sreelaskshmi,

    Thank you for your patience.

    RadAutoCompleteBox doesn't support selecting the selected items and clear them using the delete key. But you can achieve such behavior by subscribing to the PreviewKeyDown event and set the SelectedItems collection of the RadAutoCompleteBox to null.

    I have created sample project which demonstrates one way which you can use to achieve such behavior. I have also added a visual notification of the items when you pressed CTRL+A key combination. I think this project is a good starting point for achieving your final behavior. You can additionally modify the project so it covers all your cases in your main application.

    Regards,
    Dinko
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top