代码之家  ›  专栏  ›  技术社区  ›  Brad Leach

通用IBindingListView实现

  •  26
  • Brad Leach  · 技术社区  · 17 年前

    有人能建议一个实现以下功能的泛型集合类的好实现吗 IBindingListView & IBindingList 界面,并提供过滤和搜索功能?

    我认为我目前的选择是:

    • 使用别人编写和测试的类
    • 继承自 BindingList<T> ,并实施 IBindingListView 接口
    • 从头开始编写自定义集合,实现 IBindingListView I目录 .

    显然,第一种选择是我的首选。

    3 回复  |  直到 7 年前
        1
  •  13
  •   Aaron Wagner    17 年前

    我使用并构建了几年前在MSDN论坛上找到的一个实现,但最近我再次搜索,发现了一个名为 BindingListView 。它看起来很不错,我只是还没有把它拉进来替换我被黑客攻击的版本。

    nuget包: Equin.ApplicationFramework.BindingListView

    示例代码:

    var lst = new List<DemoClass>
    {
        new DemoClass { Prop1 = "a", Prop2 = "b", Prop3 = "c" },
        new DemoClass { Prop1 = "a", Prop2 = "e", Prop3 = "f" },
        new DemoClass { Prop1 = "b", Prop2 = "h", Prop3 = "i" },
        new DemoClass { Prop1 = "b", Prop2 = "k", Prop3 = "l" }
    };
    dataGridView1.DataSource = new BindingListView<DemoClass>(lst);
    // you can now sort by clicking the column headings 
    //
    // to filter the view...
    var view = (BindingListView<DemoClass>)dataGridView1.DataSource;            
    view.ApplyFilter(dc => dc.Prop1 == "a");
    
        2
  •  3
  •   Tun    15 年前

    以下是方法2和3的帮助 幕后:实现Windows窗体数据绑定的过滤

    http://www.microsoft.com/downloads/details.aspx?FamilyID=4af0c96d-61d5-4645-8961-b423318541b4&displaylang=en

        3
  •  1
  •   Joseph Daigle Sarabpreet Singh Anand    17 年前

    我能想到几个解决方案:

    1. 这个 SubSonic Project 有一个相当不错的实现 BindlingList<T> 它是开源的。尽管这可能需要使用整个SubSonic二进制文件来使用它们的实现。

    2. 我喜欢使用来自 Power Collections 项目。从那里的一个基集合继承并实现是相当简单的 IBindingListView .

    推荐文章