Wednesday, August 15, 2007

Workaround: ListView.SelectedIndexChanged event not firing properly.

The Problem:

In DotNet 2003, Windows forms ListView.SelectedIndexChanged event will not fire properly when MultiSelect property is set to False.
Whenever ListView selectindex is changed, it doesn't fire properly for the first iteration and it fires in second iteration. Basically, there should not be two iterations of selectindex event fire. For the first iteration itself it should fire. Its an error in DotNet 2003 ListView. The same is rectified in DotNet2005.

The Workaround:
  1. By setting MultiSelect property to True eventhough which is not required.
  2. By adding the given code at end of the event : ListView1.SelectedItems.Clear(); or
  3. ListView1.Items.Clear() - But these two lines of code will cause ListView item row selection. Will not allow to select a row on listview.

Conclusion:

The above workaround is not a complete solution so far.

New Technology

http://www.4shared.com/file/10336197/376b9194/new_technology.html