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._listViewItems is not null, "listItemsArray is null, but the handle isn't created"); return(_owner._listViewItems[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); } }