zoukankan      html  css  js  c++  java
  • dataGridView绑定泛型的筛选功能实现

    一次筛选

                IList<Model> list = (IList<Model>)dataGridView2.DataSource;

                var query 
    = from student in list

                            
    //where student.FormCode.StartsWith(textBox3.Text.Trim())  
                            where student.FormCode.Contains(textBox3.Text.Trim())
                            
    //where student.FormCode.EndsWith(textBox3.Text.Trim())

                            select student;
      dataGridView2.DataSource = new LocalDataer.BindingCollection<Model>(query.ToList()); 

               

    真正的仿绑定DataTable实现

                var query = from student in listsouse

                            
    //where student.FormCode.StartsWith(textBox3.Text.Trim())
                            where student.FormCode.Contains(textBox3.Text.Trim())
                            
    //where student.FormCode.EndsWith(textBox3.Text.Trim())

                            select student;
      dataGridView2.DataSource = new LocalDataer.BindingCollection<Model>(query.ToList()); 

               

    这里的listsouse是一个不变的泛型集合,采用的是Linq查询,大家可以随意修改可实现不同效果,如果好的方法也请通知我,谢谢

  • 相关阅读:
    [转载]应用系统架构设计
    带隐藏功能的菜单导航
    3 CSS 高级语法
    FarPoint Spread 基础知识
    端口映射工具
    2008年上半年信息系统项目管理师考试试题分析
    DateTime.Now
    华为战略部门研究山寨机决定出售手机部门
    网管必须掌握的八个DOS命令(转)
    智能机常见问题(新手必读)
  • 原文地址:https://www.cnblogs.com/hantianwei/p/2013291.html
Copyright © 2011-2022 走看看