将DataGridView保存到Xml [英] save DataGridView to Xml

查看:342
本文介绍了将DataGridView保存到Xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Gurus,

我想将我的Windows窗体上的未绑定DataGridView的状态保存到XML文件,以便稍后将其加载回来。


基本上,在我的表单上我有一个DataGridView,它有一些

DataGridViewTextBoxCell,DataGridViewComboBoxCell等,我想导出所有

到XML ..


非常感谢任何帮助。

解决方案

< blockquote>你真的想把TextBox,ComboBox和数据保存到XML文件吗?


一般来说DataGrids正在显示来自DataSet的数据,你可以保存

通过DataSet.WriteXml()方法在DataSet中的数据。

DataSet类:
http://msdn.microsoft.com/library/de ... ClassTopic.asp


我想存储的是那些项目的价值,而我可以迭代

逐行创建xml文件,我宁愿使用数据集和

WriteXml方法,但由于某种原因,我无法对未绑定的

DataGridView这样做。用户创建行并设置值,然后当他们点击保存时,我想将所有数据输出到XML文件,理想情况下,我想要

extract DataGridView的DataSet使用提到的WriteXML

方法将其保存到XML,但我无法得到它。


我有意义吗?


" A.Kahtava" < KA ***** @ gmail.com>在消息中写道

news:11 ********************** @ z34g2000cwc.googlegr oups.com ...

你真的想将TextBox,ComboBox和数据保存到XML文件吗?

一般来说DataGrids正在显示来自DataSet的数据,你可以在DataSet中保存数据通过DataSet.WriteXml()方法。

DataSet类:
http://msdn.microsoft.com/library/de...ClassTopic.asp


任何人?


" Henok Girma" <无**** @ spamfree.com>在消息中写道

新闻:Qd5Rf.817925


Hello Gurus,
I want to save the state of an unbound DataGridView on my Windows Form
application to an XML file so i can later load it back..

Basically, on my form I have a DataGridView, it''s got some
DataGridViewTextBoxCell, DataGridViewComboBoxCell etc, i want to export all
that to XML..

Any help is greatly appreciated.

解决方案

Do you really want to save a TextBox, ComboBox and data to an XML file?

Generally DataGrids are displaying data from a DataSet, you can save
the data within a DataSet through the DataSet.WriteXml() method.

The DataSet Class:
http://msdn.microsoft.com/library/de...ClassTopic.asp


What i wanted to store was the value of those items, while i can iterate
create line by line the xml file, i would much rather use the dataset and
WriteXml method, but for some reason i was not able to do so for an unbound
DataGridView. the user creates the rows and sets the values, then when they
click save, i want to output all the data to an XML file, idealy, i want to
extract the DataSet of the DataGridView to save it to XML using the WriteXML
method mentioned, but i was not able to get it.

Do i make sense?

"A.Kahtava" <ka*****@gmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...

Do you really want to save a TextBox, ComboBox and data to an XML file?

Generally DataGrids are displaying data from a DataSet, you can save
the data within a DataSet through the DataSet.WriteXml() method.

The DataSet Class:
http://msdn.microsoft.com/library/de...ClassTopic.asp



anyone?

"Henok Girma" <no****@spamfree.com> wrote in message
news:Qd5Rf.817925


这篇关于将DataGridView保存到Xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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