我有对象的泛型列表。每个对象都有9字符串属性。我希望把这个列表变成数据集,我可以传递到一个DataGridView ......最新最好的方式去这样做呢?
I have a Generic list of Objects. Each object has 9 string properties. I want to turn that list into a dataset that i can pass to a datagridview......Whats the best way to go about doing this?
推荐答案你试过列表绑定,直接在DataGridView?如果没有,尝试,首先因为这将节省您大量的痛苦。如果你已经尝试过了,请告诉我们什么地方出了错,所以我们可以更好地提供建议。数据绑定为您提供了不同的行为取决于什么接口的数据对象实现。例如,如果你的数据对象只实现的IEnumerable (如列表),你会得到非常基本的单向绑定,但如果它实现 IBindingList的以及(如的BindingList ,数据视图),那么你得到双向绑定。
Have you tried binding the list to the datagridview directly? If not, try that first because it will save you lots of pain. If you have tried it already, please tell us what went wrong so we can better advise you. Data binding gives you different behaviour depending on what interfaces your data object implements. For example, if your data object only implements IEnumerable (e.g. List), you will get very basic one-way binding, but if it implements IBindingList as well (e.g. BindingList, DataView), then you get two-way binding.
更多推荐
通用转换列表数据集在C#
发布评论