开发者

How to get the index of the recently selected item in a list box

I have a listbox in which i have some items. I select some items in the listbox. The condition is that i want the sele开发者_高级运维ction to be continuous. If I select any other item in listbox which is not continuous with the selection,that item should be deselected immediately. I need to have the index of recently selected item which i tried to get with the help of SelectionChangedEvent but it gives me the index of first selected item. How to do that?


You're looking for the last item in the SelectedIndices collection.


Keep the indicies of those continously selected items somewhere.

When any item is selected or unselected, catch this in SelectionChanged event. Check the SelectedIndicies collection, like SLaks suggested, to see if something except than your collection is selected, or if some of it's items were unselected. If you need, restore the presentation of listBox.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜