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

Reset List Control to No Selected Item

2 Answers 99 Views
ListControl
This is a migrated thread and some comments may be shown as answers.
im
Top achievements
Rank 2
im asked on 15 Feb 2013, 06:25 PM
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 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 20 Feb 2013, 03:20 PM
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.
0
im
Top achievements
Rank 2
answered on 21 Feb 2013, 12:27 AM
Thanks for the Position property, I missed that from the base class. It works fine now. thank you
Tags
ListControl
Asked by
im
Top achievements
Rank 2
Answers by
Ivan Petrov
Telerik team
im
Top achievements
Rank 2
Share this question
or