///重载构造函数,根据所给dgv转换为SiftItem,传入Indexs可隐藏不想显示的列(某些列不需要显示,比如经过转换后的列【1.是 0.否】) public FrmSift(DataGridView dgv, params int[] indexs) { InitializeComponent(); List <SiftItem> lst = new List <SiftItem>(); for (int i = 0; i < dgv.Columns.Count; i++) { if (!dgv.Columns[i].Visible) { continue; } if (indexs != null && Array.IndexOf(indexs, i) != -1) { continue; } if (dgv.Columns[i].ValueType == null) { continue; } SiftItem item = new SiftItem(dgv.Columns[i].HeaderText, dgv.Columns[i].Name, dgv.Columns[i].ValueType); lst.Add(item); } items = lst.ToArray(); }
///筛选,使用DataTable的Select方法筛选 private void linklblSift_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (Items == null) { Items = new SiftItem[_dtSource.Columns.Count]; for (int i = 0; i < _dtSource.Columns.Count; i++) { Items[i] = new SiftItem(); Items[i].Display = _dtSource.Columns[i].ColumnName; Items[i].Value = _dtSource.Columns[i].ColumnName; Items[i].SiftType = SiftTypeEnum.Text; } } FrmSift frm = new FrmSift(Items); frm.Text = "筛选"; frm.ShowDialog(); if (frm.DialogResult != DialogResult.OK) { return; } _filter = frm.StrWhere; BindData(); }
private void FrmFilter_Load(object sender, EventArgs e) { SiftItem[] items = new SiftItem[4]; items[0] = new SiftItem("编号", "编号", typeof(string)); items[1] = new SiftItem("姓名", "姓名", typeof(string)); items[2] = new SiftItem("工资", "工资", typeof(decimal)); items[3] = new SiftItem("生日", "生日", typeof(DateTime)); ucFilter1.Items = items; ucFilter1.Binding(Data, new string[0]); }
///重载构造函数,根据所给dgv转换为SiftItem,传入Indexs可隐藏不想显示的列(某些列不需要显示,比如经过转换后的列【1.是 0.否】) public FrmSift(DataGridView dgv, params int[] indexs) { InitializeComponent(); List<SiftItem> lst = new List<SiftItem>(); for (int i = 0; i < dgv.Columns.Count; i++) { if (!dgv.Columns[i].Visible) continue; if (indexs != null && Array.IndexOf(indexs, i) != -1) continue; if (dgv.Columns[i].ValueType == null) { continue; } SiftItem item = new SiftItem(dgv.Columns[i].HeaderText, dgv.Columns[i].Name, dgv.Columns[i].ValueType); lst.Add(item); } items = lst.ToArray(); }
///筛选,使用DataTable的Select方法筛选 private void linklblSift_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (Items == null) { Items = new SiftItem[_dtSource.Columns.Count]; for (int i = 0; i < _dtSource.Columns.Count; i++) { Items[i] = new SiftItem(); Items[i].Display = _dtSource.Columns[i].ColumnName; Items[i].Value = _dtSource.Columns[i].ColumnName; Items[i].SiftType = SiftTypeEnum.Text; } } FrmSift frm = new FrmSift(Items); frm.Text = "筛选"; frm.ShowDialog(); if (frm.DialogResult != DialogResult.OK) return; _filter = frm.StrWhere; BindData(); }
///重载构造函数,使用SiftItem[]构造 public FrmSift(SiftItem[] items) { InitializeComponent(); this.items = items; }