private bool CheckFilter(TBListViewItem item) { bool match = false; for (int i = 0; i < item.SubItems.Count; i++) { if (filters[i] != "") { if (columnsWithDateSorting.Contains(i)) { match = FilterByDate(i, item.additionalItem); } else if (item.SubItems[i].Text.IndexOf(filters[i], StringComparison.OrdinalIgnoreCase) >= 0) { match = true; } else { return(false); } } } return(match); }
public override object Clone() { object clone = base.Clone(); TBListViewItem item = (TBListViewItem)clone; item.additionalItem = this.additionalItem; return(item); }
public void Filter(int filterNumber, string Value) { filters[filterNumber] = Value; if (Value == "") { if (FiltersAreClear()) { ClearFilters(); return; } } if (filtersWasClear) { filtersWasClear = false; buffor_array = new TBListViewItem[Items.Count]; //Items.CopyTo(buffor_array, 0); for (int itemIndex = 0; itemIndex < Items.Count; itemIndex++) { //TBListViewItem source = (TBListViewItem)Items[itemIndex]; TBListViewItem item = (TBListViewItem)Items[itemIndex].Clone(); buffor_array[itemIndex] = item; } allListViewBuffered = buffor_array.Cast <TBListViewItem>(); } Items.Clear(); var matchedItems = from TBListViewItem in allListViewBuffered where CheckFilter(TBListViewItem) select TBListViewItem; foreach (TBListViewItem item in matchedItems) { this.Items.Add((TBListViewItem)item.Clone()); } }
private void AddToList(Database.Client c) { Database.Address ad = c.GetAddress(); string phone = ""; string mail = ""; if (c.p_numbers.Length > 0) { phone = c.p_numbers[0]; } if (c.emails.Length > 0) { mail = c.emails[0]; } TBListViewItem item = new TBListViewItem(new string[] { c.name, c.NIP, ad.street, ad.city, phone, mail, c.notes, c.ser_agr ? "tak" : "nie" }, c); this.Items.Add(item); }