public ListViewItem Insert (int index, ListViewItem item)
{
if (index < 0 || index > list.Count)
throw new ArgumentOutOfRangeException ("index");
if (owner != null && owner.VirtualMode)
throw new InvalidOperationException ();
if (list.Contains (item))
throw new ArgumentException ("An item cannot be added more than once. To add an item again, you need to clone it.", "item");
if (item.ListView != null && item.ListView != owner)
throw new ArgumentException ("Cannot add or insert the item '" + item.Text + "' in more than one place. You must first remove it from its current location or clone it.", "item");
if (is_main_collection)
item.Owner = owner;
else {
if (item.Group != null)
item.Group.Items.Remove (item);
item.SetGroup (group);
}
list.Insert (index, item);
if (is_main_collection || item.ListView != null)
CollectionChanged (true);
// force an update of the selected info if the new item is selected.
if (item.Selected)
item.SetSelectedCore (true);
//UIA Framework event: Item Added
OnUIACollectionChangedEvent (new CollectionChangeEventArgs (CollectionChangeAction.Add, item));
return item;
}