Reset List Control to No Selected Item

3 posts, 0 answers
  1. im
    im avatar
    27 posts
    Member since:
    Mar 2012

    Posted 15 Feb 2013 Link to this post

    What I am trying to do is cancel the SelectedIndexChanged event in the list control, (which I know you cant). I know you can cancel the IndexChanging event, however it doesnt provide which item it is changing to, so that does no good.

    I want the user to select an item from the list, then I get which item they selected, do some work, then reset the list control to nothing being selected again. So if they click the same item twice, i can "do something again", however if the item is selected already the event doesn't change.  

    The closest Ive been able to come is during the SelectedItemChanging event, is to change the ListControl SelectionMode = None, which removes the theme for the selected item, and sets all the selected Item, value, index, and active to the default values. GREAT... 

    Then switch it back to One, and all the no selected item default values are still there, Perfect...

    However when you select the same Item again, the Items UI becomes selected again, but the  SelectedItemChanged event does NOT fire again.  I put a break point on the SelectedItemChanging event, and all the previous selected Item information was back again, NOT good,

    I even re-bound the Event handler just in case it got cleared out to, still no luck.
    private void ListPlacesSelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
            {
     
    .....DO Something
     
                this.listPlaces.ActiveItem = null;
                this.listPlaces.SelectionMode = SelectionMode.None;
                this.listPlaces.SelectionMode = SelectionMode.One;
                this.listPlaces.SelectedIndexChanged += ListPlacesSelectedIndexChanged;
     
            }


    Any better ideas?

    Thanks

     
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 20 Feb 2013 Link to this post

    Hi Derek,

    Thank you for writing.

    I tried to reproduce the issue you have described with the SelectedIndexChanging but was unable to do so. The Position property of the event arguments is the index of the item that is about to be selected. Having the index you can easily retrieve the item that will be selected through the list control Items collection. I tested the case with our latest release which is Q3 SP1 2012 at the moment. If this is not the version of the controls you are using, I would kindly ask you to send me the version of the controls you are using so I can give you an adequate solution.

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Kind regards,
    Ivan Petrov
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. im
    im avatar
    27 posts
    Member since:
    Mar 2012

    Posted 20 Feb 2013 Link to this post

    Thanks for the Position property, I missed that from the base class. It works fine now. thank you
Back to Top