/// <summary> /// This is a useful default implementation of SearchText method, intended to be called /// by implementors of IVirtualListDataSource. /// </summary> /// <param name="value"></param> /// <param name="first"></param> /// <param name="last"></param> /// <param name="column"></param> /// <param name="source"></param> /// <returns></returns> public static int DefaultSearchText(string value, int first, int last, OLVColumn column, IVirtualListDataSource source) { if (first <= last) { for (int i = first; i <= last; i++) { string data = column.GetStringValue(source.GetNthObject(i)); if (data.StartsWith(value, StringComparison.CurrentCultureIgnoreCase)) { return(i); } } } else { for (int i = first; i >= last; i--) { string data = column.GetStringValue(source.GetNthObject(i)); if (data.StartsWith(value, StringComparison.CurrentCultureIgnoreCase)) { return(i); } } } return(-1); }
public AutoCompleteCellEditor(ObjectListView lv, OLVColumn column) { this.DropDownStyle = ComboBoxStyle.DropDown; Dictionary <String, bool> alreadySeen = new Dictionary <string, bool>(); for (int i = 0; i < Math.Min(lv.GetItemCount(), 1000); i++) { String str = column.GetStringValue(lv.GetModelObject(i)); if (!alreadySeen.ContainsKey(str)) { this.Items.Add(str); alreadySeen[str] = true; } } this.Sorted = true; this.AutoCompleteSource = AutoCompleteSource.ListItems; this.AutoCompleteMode = AutoCompleteMode.Append; }