virtual protected ListViewItem CreateItem(DataSourceObject data) { List <String> subItems = new List <String>(); foreach (ColumnHeader col in Columns) { var pName = col.Tag.ToString(); if (pName == null || pName == String.Empty || !data.HasProperty(pName)) { throw new Exception(String.Format("Cannot find property for column {0} using property name {1}", col.Name, pName)); } var val = data.Get <Object>(pName); subItems.Add(val == null ? String.Empty : val.ToString()); } ListViewItem lvi = new ListViewItem(subItems.ToArray()); lvi.Name = GetID(data); return(lvi); }
public bool Matches(DataSourceObject data) { if (data == null) { throw new Exception("Cannot match on null data"); } String[] propertyNames = PropertyName.Split('|'); foreach (var pName in propertyNames) { foreach (var kv in Controls) { Control c = kv.Key; List <Object> values = kv.Value; if (c is TextBox) { var s1 = ((TextBox)c).Text; if (s1 == null || s1 == String.Empty) { return(true); } s1 = s1.ToLower(); var s2 = data.Get <String>(pName).ToLower(); if (s2.IndexOf(s1) >= 0) { return(true); } } else if (c is CheckBox) { if (((CheckBox)c).Checked && values.Contains(data.Get <Object>(pName))) { return(true); } } else if (c is ComboBox) { var cmb = (ComboBox)c; if (cmb.SelectedIndex == -1 || cmb.SelectedItem == null || ((String)cmb.SelectedItem) == String.Empty || values.Contains((String)cmb.SelectedItem)) { return(true); } var val = data.Get <Object>(pName); if (val.ToString() == ((String)cmb.SelectedItem)) { return(true); } } else if (c is ListView) { var lv = (ListView)c; if (lv.SelectedItems == null || lv.SelectedItems.Count == 0) { return(true); } var val = data.Get <String>(pName); foreach (ListViewItem lvi in lv.SelectedItems) { if (lvi.Name == val) { return(true); } } } else { throw new Exception("ChetchListView::MatchesFilter does not support control " + c.GetType().ToString()); } } } return(false); }
protected String GetID(DataSourceObject data) { return(data.Get <String>(DataSourceObjectIDName)); }