通用转换列表数据集在C# [英] Convert generic list to dataset in C#

查看:101
本文介绍了通用转换列表数据集在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有对象的泛型列表。每个对象都有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#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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