void FastObjectListView_SearchForVirtualItem(object sender, SearchForVirtualItemEventArgs e) { // The event has e.IsPrefixSearch, but as far as I can tell, this is always false (maybe that's different under Vista) // So we ignore IsPrefixSearch and IsTextSearch and always to a case insensitve prefix match int increment = (e.Direction == SearchDirectionHint.Up ? -1 : 1); OLVColumn column = this.GetColumn(0); if (this.IsSearchOnSortColumn && this.View == View.Details && this.lastSortColumn != null) { column = this.lastSortColumn; } int i; for (i = e.StartIndex; i >= 0 && i < this.objectList.Count; i += increment) { string data = column.GetStringValue(this.objectList[i]); if (data.StartsWith(e.Text, StringComparison.CurrentCultureIgnoreCase)) { e.Index = i; return; } } // Also the LVFINDINFO has a LV_WRAP flag, but the SearchForVirtualItemEventArgs does not. Why? // We always wrap i = (increment < 0 ? this.objectList.Count : 0); while ((increment < 0 && i > e.StartIndex) || (increment > 0 && i < e.StartIndex)) { string data = column.GetStringValue(this.objectList[i]); if (data.StartsWith(e.Text, StringComparison.CurrentCultureIgnoreCase)) { e.Index = i; return; } i += increment; } }
/// <summary> /// Generate aspect getters and putters for any columns that are missing them (and for which we have /// enough information to actually generate a getter) /// </summary> protected void CreateMissingAspectGettersAndPutters() { for (int i = 0; i < this.Columns.Count; i++) { OLVColumn column = this.GetColumn(i); if (column.AspectGetter == null && !String.IsNullOrEmpty(column.AspectName)) { column.AspectGetter = delegate(object row) { try { // In most cases, rows will be DataRowView objects return(((DataRowView)row)[column.AspectName]); } catch { return(column.GetAspectByName(row)); } }; } if (column.IsEditable && column.AspectPutter == null && !String.IsNullOrEmpty(column.AspectName)) { column.AspectPutter = delegate(object row, object newValue) { try { // In most cases, rows will be DataRowView objects ((DataRowView)row)[column.AspectName] = newValue; } catch { column.PutAspectByName(row, newValue); } }; } } }
public ColumnComparer(OLVColumn col, SortOrder order) { this.column = col; this.sortOrder = order; this.secondComparer = null; }