I am using a WinForms ListView in details mode (.NET 4.0, running on Windows 7) and I have a function that needs to clear the subitems in a particular item. Unfortunately w
Please note 1:
The ListViewItem.Text
(not the Name
) is the ListViewItem.SubItems[0]
, but:
the ListViewItem.SubItems.Clear()
clears also the ListViewItem.Name
!
So, if you use SubItems.Clear
, you then have to restore both Name
and Text
(if you need them).
Please note 2:
If you use *Key
methods (eg. ListView.Items.ContainsKey()
or ListView.Items.RemoveByKey()
) to access the items (instead of *Index
ones), take care of the ListViewItem.Name
, which is the key
you need to pass to these methods...
What a smart logic...
For the case anyone is forced or wants to use ListView
I have discovered another problem described in question 23007388.
As it might take very long time to determine all this stuff, I have posted this answer even this thread is a little bit old.