Codelog

foreach(Snippet aSnippet in CodeLog){ aSnippet.GetSolution(); }

DoUNo: ListView_ItemSelectionChangedEvent and MultiSelect

without comments

Today, I was trying to customise ListViewControl by playing with the item drawn event, thats when I came across this peculiar stuff.

In ListView, if you have subscribed for the ItemSelectionChangedEvent,the event will not be raised, if you select the same item more than once provided the ListView.MultiSelect = false;  Shhh. Quite difficult to understand, isn’t it ??

Ok. An example, Lets consider that  we have a list view control with two items, foo and bar. Also consider that we have subscribed for the ItemSelectionChangedEvent and the ListView’s MultiSelect is true. Now if you run the application keeping a break point in the ItemSelectionChangedEventHandler and if you select the item foo again and again the control will break. On the other hand, if your ListView’s MultiSelect is false, the control won’t hit the break point. Which means that the event will not be raised.

Written by sudarsanyes

February 22nd, 2009 at 10:32 pm

Leave a Reply