c# - 如何在 WinForms 项目中将 XML 用作 DataGridView 的数据源?

标签 c# .net xml winforms datagridview

如何将可编辑的 DataGridView 链接到 WinForms 项目中的 XML 文件?

最佳答案

这里MSDN推荐的最简单的方法http://msdn.microsoft.com/en-us/magazine/cc163669.aspx是将其加载到数据集中。

Q Can you tell me the best way to bind XML data to a DataGridView control?

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.

DevX 此处提供了一整套代码,还有一个教程可以帮助您通过数据集将 DataGridView 绑定(bind)到 XML。 http://www.devx.com/dotnet/Article/28678/1954

希望这对您有所帮助。

关于c# - 如何在 WinForms 项目中将 XML 用作 DataGridView 的数据源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/265604/

相关文章:

Php 从 xml 节点获取特定值(调用节点名称)

c# - 快速多字符串替换

c# - 如何在 C# 中将 SQL 解析为数据表或数组?

c# - 同步访问由定时器重置的状态变量

c# - 如何在 Microsoft Graph 中使用 DI

XML Odoo 字段条件颜色格式

c# - 找不到命名空间或数据类型 NavMeshAgent Unity 3d

c# - 列表中的字符串分隔

c# - 将整个 C# 控制台应用程序打包在一个文件中?

C# LINQ Xml查询混淆