Why does SubItems.Clear() also delete the Name attribute?

后端 未结 3 1709
無奈伤痛
無奈伤痛 2021-01-19 04:57

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

3条回答
  •  时光取名叫无心
    2021-01-19 05:50

    From MSDN:

    Note

    The first subitem in the ListViewItem.ListViewSubItemCollection is always the item that owns the subitems. When performing operations on subitems in the collection, be sure to reference index position 1 instead of 0 to make changes to the first subitem.

    Thus, clearing the sub items collection, clears the values for the parent as well.

提交回复
热议问题