BrightIdeasSoftware.VirtualObjectListView.GetPreviousItem C# (CSharp) Метод

GetPreviousItem() публичный Метод

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 ( BrightIdeasSoftware.OLVListItem itemToFind ) : BrightIdeasSoftware.OLVListItem
itemToFind BrightIdeasSoftware.OLVListItem The item that is before the item that is returned
Результат BrightIdeasSoftware.OLVListItem
        public override OLVListItem GetPreviousItem(OLVListItem itemToFind)
        {
            if (!this.ShowGroups)
                return base.GetPreviousItem(itemToFind);

            // Sanity
            if (this.OLVGroups == null || this.OLVGroups.Count == 0)
                return null;

            // If the given items is null, return the last member of the last group
            if (itemToFind == null) {
                OLVGroup lastGroup = this.OLVGroups[this.OLVGroups.Count - 1];
                return this.GetItem(this.GroupingStrategy.GetGroupMember(lastGroup, lastGroup.VirtualItemCount - 1));
            }

            // Find where this item occurs (which group and where in that group)
            int groupIndex = this.GroupingStrategy.GetGroup(itemToFind.Index);
            int indexWithinGroup = this.GroupingStrategy.GetIndexWithinGroup(this.OLVGroups[groupIndex], itemToFind.Index);

            // If it's not the first member of the group, just return the previous member
            if (indexWithinGroup > 0)
                return this.GetItem(this.GroupingStrategy.GetGroupMember(this.OLVGroups[groupIndex], indexWithinGroup - 1));

            // The item is the first member of its group. Return the last member of the previous group
            // (if there is one)
            if (groupIndex > 0) {
                OLVGroup previousGroup = this.OLVGroups[groupIndex - 1];
                return this.GetItem(this.GroupingStrategy.GetGroupMember(previousGroup, previousGroup.VirtualItemCount - 1));
            }

            return null;
        }