Another option:
Have a form level variable of type ListViewItem and set it to null:
private ListViewItem _curItem = null;
In the ItemChecked event, have:
if (_curItem != null)
{
_curItem.Checked = false;
}
_curItem = e.Item;
"sklett" wrote:
> I wasn't sure how to deal with this, but this is what I cam up with. If
> possible, I'd like a little feedback if there is a better way to deal with a
> situation where changes in an event handler cause the event to fire.
>
> private void listView_AvailableTests_ItemChecked(object sender,
> ItemCheckedEventArgs e)
> {
> listView_AvailableTests.ItemChecked -=
> listView_AvailableTests_ItemChecked;
>
> foreach(ListViewItem item in listView_AvailableTests.Items)
> {
> if(item != e.Item)
> {
> item.Checked = false;
> }
> }
>
> listView_AvailableTests.ItemChecked +=
> listView_AvailableTests_ItemChecked;
> }
>
> The above code works, but it just seems a little "odd" to me for some reason
> ;0)
>
> Any and all comments are welcome.
>
> Thanks,
> Steve
>
>
>
|