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查询,大家可以随意修改可实现不同效果,如果好的方法也请通知我,谢谢

  • 相关阅读:
    Win32汇编
    Boost ASIO 实现异步IO远控
    Python 使用oslo.vmware管理ESXI虚拟机
    Python 巡检接入钉钉机器人
    Django Ajax序列化与反序列化
    Nacos 认证绕过
    Lanproxy 遍历目录漏洞 CVE-2021-3019 附批量POC
    Apache Solr 全版本任意读取文件漏洞
    垂直水平居中的多种方法 主要的4种
    vue provide/inject 父组件如何给孙子组件传值
  • 原文地址:https://www.cnblogs.com/hantianwei/p/2013291.html
Copyright © 2011-2022 走看看