public ListViewItem this[int displayIndex] { get { owner.ApplyUpdateCachedItems(); if (owner.VirtualMode) { // if we are showing virtual items, we need to get the item from the user RetrieveVirtualItemEventArgs rVI = new RetrieveVirtualItemEventArgs(displayIndex); owner.OnRetrieveVirtualItem(rVI); rVI.Item.SetItemIndex(owner, displayIndex); return(rVI.Item); } else { if (displayIndex < 0 || displayIndex >= owner.itemCount) { throw new ArgumentOutOfRangeException(nameof(displayIndex), displayIndex, string.Format(SR.InvalidArgument, nameof(displayIndex), displayIndex)); } if (owner.IsHandleCreated && !owner.ListViewHandleDestroyed) { return((ListViewItem)owner.listItemsTable[DisplayIndexToID(displayIndex)]); } else { Debug.Assert(owner.listItemsArray is not null, "listItemsArray is null, but the handle isn't created"); return((ListViewItem)owner.listItemsArray[displayIndex]); } } } set { owner.ApplyUpdateCachedItems(); if (owner.VirtualMode) { throw new InvalidOperationException(SR.ListViewCantModifyTheItemCollInAVirtualListView); } if (displayIndex < 0 || displayIndex >= owner.itemCount) { throw new ArgumentOutOfRangeException(nameof(displayIndex), displayIndex, string.Format(SR.InvalidArgument, nameof(displayIndex), displayIndex)); } if (owner.ExpectingMouseUp) { owner.ItemCollectionChangedInMouseDown = true; } RemoveAt(displayIndex); Insert(displayIndex, value); } }