How can I resize an existing ListItemCollection I have a listview that I wan't to populate using ListItemCollection.Insert(). I am using Insert the Instead method of the Add method because I wan't to control where the item is inserted.
I get an exception when I try to add an item at an index that is beyond the size of the ListItemCollection. How can I expand the ListItemCollection before I call Insert I am missing a Resize method.
Do you have any suggestions
Thanks,
Bo

Expanding a ListItemCollection
A. Reimann
I am sorry, I meant a ListView.ListViewItemCollection
/Bo
Arie Ori
I think you use ListView.Items(index) = **** and you get an exception, so, use :
ListView.Items.Add()
This will resize (automatically) ListView.Items.
Hope this helps a bit...
Nicolo Carandini
I wanted to use the Insert method instead of the Add method because I wan't to control where the items are inserted in the list.
I have found a workaround which is to use the Add method and then subsequently sort the list with a custom list item sorter that orders the items as I want them.
/Bo
Youngmin park
Venaddar
ListView.Items.Insert() will resize ListView.Items automatically too, try this code :
ListView1.Items.Insert(0, New ListViewItem("Test"))
You will not get any exception :)
Ananth Iyer
hi,
Is your problem solved If yes then could you please mark the reply as answered.
Thank you,
Bhanu.
J.S.
ListBox.Items.Count is read-only, so, use ListBox.Items.Insert() or ListBox.Items.Add()...
Hope this helps a bit.