任何人都可以建议一个通用集合类的良好实现,该集合类实现了 IBindingListView & IBindingList 接口并提供过滤和搜索功能?

我认为我当前的选择是:

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

显然,第一个选项是我的首选。

有帮助吗?

解决方案

我使用并构建了我在几年前的旧 MSDN 论坛帖子上找到的实现,但最近我再次搜索并发现了一个名为的 sourceforge 项目 绑定列表视图. 。它看起来很不错,我只是还没有将它替换为我的破解版本。

努吉特包: 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幕后方法的帮助:实现 Windows 窗体数据绑定的过滤

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

我能想到的几个解决方案:

  1. 亚音速项目 有一个很好的实现 BindlingList<T> 这是开源的。尽管这可能需要使用整个 SubSonic 二进制文件来使用它们的实现。

  2. 我喜欢使用以下课程 能量收集 项目。从那里的基本集合之一继承并实现是相当简单的 IBindingListView.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top