创建自定义数据表是可绑定到WinForms控件? [英] Create custom DataTable which is bindable to WinForms controls?

查看:149
本文介绍了创建自定义数据表是可绑定到WinForms控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的店主要使用ADO对象(我指的是数据集数据表和<$ C C>的DataRow )$封送各地数据和表格,并在网格操纵它。我们正在尝试创造店味同行的原生ADO对象,以便我们能够强加我们的内部标准在它们之上。

Our shop primarily use "ADO objects" (I'm referring to DataSet, DataTable, and DataRow) for marshaling around data and manipulating it on forms and in grids. We are experimenting with creating shop-flavored counterparts to the native ADO objects so that we can impose our in-house standards on top of them.

实现这个很简单但有一个例外:我希望我们的对象是绑定的控件。

Implementing this is straightforward with one exception: I want our objects to be bindable to controls.

我知道的IList,IBindingList的,BindingSource的,等等,并已经看过,并试验了这些,但我未能达到,当涉及到制造类的没有硬属性名的可绑定。原生的ADO对象不强默认类型。您有您通过项目属性来访问列值(如行(时代) row.Item(时代))。结合例子,我在网上找到应对强类型的对象(例如 row.Age )。从本质上讲,我们要创建自定义的ADO对象(而不是从本民族的继承)仍然保留其结合控制的能力。

I'm aware of IList, IBindingList, BindingSource, etc. and have looked at and experimented with these, but I am falling short when it comes to making a class with no hard property names bindable. The native ADO objects are not strongly typed by default. You have column values that you access via the Item property (e.g. row("Age") or row.Item("Age")). The binding examples I've found online deal with strong-typed objects (e.g. row.Age). Essentially, we want to create custom ADO objects (not inherited from the native ones) that still retain their ability to bind to controls.

有如何实现这一点的一个最基本的例子吗?

在一个网格我希望看到的列名称年龄职业从一排,其中这些属性通过行(名称),行(时代)行(职业)。这必须是可行的,因为这正是本土数据表的DataRow 提供。

In a grid I would expect to see columns Name, Age and Occupation from a row where these properties are exposed via row("Name"), row("Age") and row("Occupation"). This must be doable as this is exactly what the native DataTable and DataRow provide.

这是一个<一个细化href="http://stackoverflow.com/questions/7181324/binding-a-dictionary-to-a-winforms-grid-or-combo">earlier问题。

推荐答案

看来你需要使用ITypedList接口,与PropertyDescriptor与配合工作。最明显的文章中,我发现这是在这里:

It seems you need to use the ITypedList interface, which works in conjunction with PropertyDescriptor. The clearest article I have found on this is here:

http://blog.lab49.com/archives/705

我曾试图这个自己而回,并将给它另一种尝试基于这篇文章。

I had attempted this myself a while back, and will be giving it another try based on this article.

这篇关于创建自定义数据表是可绑定到WinForms控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆