nazim corakli nazim corakli - 1 month ago 22
C# Question

Different listview columns copy error

I have 2 listviews:


  • listview1 has 5 columns (0, 1, 2, 3, 4)

  • listview2 has 20 columns (0, 1, 2,.., 18, 19)



I want to copy items from listview1 to listview2.

Then I have to write something

listview2.items[0].subitems[5]


but I cannot write. There is no columns here. But listview1 has 20 columns.

Anybody knows this problem's solution?

(I have to use copy function. I cannot move items one by one.)

Answer

Just because the listview has 20 columns, doesn't mean that every item has 19 subitems. You still have to use the .Add or .AddRange method to give value to all the possible subitems.