BrightIdeasSoftware.ObjectListView.GetPreviousItem C# (CSharp) Method

GetPreviousItem() public method

Return the ListViewItem that appears immediately before the given item. If the given item is null, the last item in the list will be returned. Return null if the given item is the first item.
public GetPreviousItem ( OLVListItem itemToFind ) : OLVListItem
itemToFind OLVListItem The item that is before the item that is returned
return OLVListItem
        public virtual OLVListItem GetPreviousItem(OLVListItem itemToFind)
        {
            if (this.ShowGroups) {
                OLVListItem previousItem = null;
                foreach (ListViewGroup group in this.Groups) {
                    foreach (OLVListItem lvi in group.Items) {
                        if (lvi == itemToFind)
                            return previousItem;

                        previousItem = lvi;
                    }
                }
                return itemToFind == null ? previousItem : null;
            }
            if (this.GetItemCount() == 0)
                return null;
            if (itemToFind == null)
                return this.GetItem(this.GetItemCount() - 1);
            if (itemToFind.Index == 0)
                return null;
            return this.GetItem(itemToFind.Index - 1);
        }
ObjectListView