BrightIdeasSoftware.ObjectListView.GetDisplayOrderOfItemIndex C# (CSharp) Method

GetDisplayOrderOfItemIndex() public method

Return the display index of the given listviewitem index. If the control is not grouped, the display order is the same as the sorted list order. But if the list is grouped, the display order is different.
public GetDisplayOrderOfItemIndex ( int itemIndex ) : int
itemIndex int
return int
        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;
        }
ObjectListView