BrightIdeasSoftware.ObjectListView.FindMatchingRow C# (CSharp) Method

FindMatchingRow() public method

Find the first row after the given start in which the text value in the comparison column begins with the given text. The comparison column is column 0, unless IsSearchOnSortColumn is true, in which case the current sort column is used.
The text comparison is a case-insensitive, prefix match. The search will search the every row until a match is found, wrapping at the end if needed.
public FindMatchingRow ( string text, int start, SearchDirectionHint direction ) : int
text string The text to be prefix matched
start int The index of the first row to consider
direction SearchDirectionHint Which direction should be searched?
return int
        public virtual int FindMatchingRow(string text, int start, SearchDirectionHint direction)
        {
            // We also can't do anything if we don't have data
            int rowCount = this.GetItemCount();
            if (rowCount == 0)
                return -1;

            // Which column are we going to use for our comparing?
            OLVColumn column = this.GetColumn(0);
            if (this.IsSearchOnSortColumn && this.View == View.Details && this.LastSortColumn != null)
                column = this.LastSortColumn;

            // Do two searches if necessary to find a match. The second search is the wrap-around part of searching
            int i;
            if (direction == SearchDirectionHint.Down) {
                i = this.FindMatchInRange(text, start, rowCount - 1, column);
                if (i == -1 && start > 0)
                    i = this.FindMatchInRange(text, 0, start - 1, column);
            } else {
                i = this.FindMatchInRange(text, start, 0, column);
                if (i == -1 && start != rowCount)
                    i = this.FindMatchInRange(text, rowCount - 1, start + 1, column);
            }

            return i;
        }
ObjectListView