问题描述
我如何在WinForms项目可编辑的DataGridView链接到一个XML文件?
How do I link an editable DataGridView to an XML file in a WinForms project?
推荐答案
推荐MSDN被这里最简单的方法http://msdn.microsoft.com/en-us/magazine/cc163669.aspx被加载到数据集。
The easiest way recommended by MSDN here http://msdn.microsoft.com/en-us/magazine/cc163669.aspx is to load it into a data set.
问:你能告诉我最好的方法将XML数据绑定到一个DataGridView控制?
这是最简单的解决方案是将XML加载到数据集并绑定到。另一种解决方案是使用XML序列化来创建一个XML并绑定到一个对象图。绑定到原始XML,你需要创建实现ITypedList,IBindingList的和ICustomTypeDescriptor包装类。
A The simplest possible solution is to load the XML into a DataSet and bind to that. Another solution would be to use XML serialization to create an object graph from the XML and bind to that. To bind to the raw XML, you would need to create wrapper classes that implement ITypedList, IBindingList, and ICustomTypeDescriptor.
有一整套code在在DevX这里的教程,可以帮助您通过数据集绑定的DataGridView到XML。 http://www.devx.com/dotnet/Article/28678/1954
There is an entire set of code over at DevX here and a tutorial that might help you with binding DataGridView to XML via data sets. http://www.devx.com/dotnet/Article/28678/1954
希望这有助于。
这篇关于如何使用XML作为数据源在一个WinForms项目一个DataGridView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!