views:

16

answers:

1

Following some SO advice I have tried the following on the ItemCheck event of a ListView control:

private void lstTasks_ItemCheck(object sender, ItemCheckEventArgs e)
    {
     ...some code

     return;
     }

The idea being that that return; will cancel the event

...but does running some code before the blank return; negate the desired result?

I want to use the ItemCheck event because it allows me to pull data via e.Index from the ListView and run some updates. When I return to the ListView the ItemCheck hasn't finished firing and will often crash the program because it can't find the desired index number due to the updates removing that item.

+1  A: 

Writing return; will not cancel the event.

Instead, you can set e.NewValue to CheckState.Checked or CheckState.Unchecked.

SLaks
Thanks @SLaks - that works well.
John M