public virtual int GetDisplayOrderOfItemIndex(int itemIndex) { if (!this.ShowGroups) return itemIndex; // TODO: This could be optimized int i = 0; foreach (ListViewGroup lvg in this.Groups) { foreach (ListViewItem lvi in lvg.Items) { if (lvi.Index == itemIndex) return i; i++; } } return -1; }