将多个Datagridview导出到1个xml vb.net [英] Multiple Datagridview export to 1 xml vb.net

查看:95
本文介绍了将多个Datagridview导出到1个xml vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,

我有一个表格,用户可以在其中输入各种数据.
这些数据应保存到1个xml文件中.

我已经看到了许多将1 datagridview导出到XML的示例,但是没有多个示例(DG1,DG2,DG3).

之后也必须导入相同的数据.

非常感谢您的专业帮助

Brgds,
RRENS

OP在答案"中添加
要添加,表单包含多个选项卡,每个选项卡包含1个datagridview.

感谢您的所有帮助.

Good day,

I have a form, where the user can enter various data.
These data shoul be saved into 1 xml file.

I''ve seen many examples of 1 datagridview exporting to XML, but not multiple (DG1, DG2,DG3).

Same data must be imported afterwards as well.

Many thanks for your professional help

Brgds,
RRENS

addition by the OP in an "answer"
To add, the form contains multiple tabs and each tab contains 1 datagridview.

Thanks for all your help

推荐答案

在这里,您需要提醒您您是软件开发人员.即使您使用了一些代码示例,您也应该了解它的工作原理,而不是将其用作食谱.您需要能够编写代码,而不是在此处四处乱七八糟的方法"将它们拼凑在一起.而且,您需要养成从头开始编写代码到需求的习惯,而不是使用应用程序,而是使用库代码(并创建此类库,扩展算法库).软件重用意味着开发和使用库,而不是复制和粘贴.

让我告诉您,一个或多个网格视图之间没有主要区别.如果您在将单个网格视图代码转换"为多个时发现问题,那么您甚至根本不尝试做任何专业的工作.此外,您应该了解,没有可以编写的仅XML"之类的东西.可以为不同的应用程序创建不同的数据模型,并且它们的结构可以表示为一些元数据,它对应于一个或另一个XML模式.相同的应用程序数据表示形式可以通过多种不同的方式进行建模,从而提供不同的方案.

此外,您看到的代码示例可能不太好.您不应该将代码保存在XML文件中的某些UI状态,而不是在UI表达某些数据集时使用.相反,您需要将UI与数据模型隔离,并将数据模型与持久性隔离.在最简单的情况下,您可以在内存中拥有数据模型的实例,并具有从数据填充UI以及从UI状态修改数据的过程.数据而不是UI应该用于持久性.一切已经为您完成,因为您可以使用数据合同,这将避免直接处理XML.请参阅:
http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ].

在我倡导这种方法的地方,也请参阅我过去的答案:
如何在我的表单应用程序? [ ^ ],
创建属性文件... [
Here is the point where you need to get a reminded that you are a software developer. Even if you used some code sample, you should have understood how it works instead of using it as a cookbook recipe. You need to be able to write code, not take fragments of code here and there trying to put them together using trial-and-error "method". And you need to get a habit to write code from scratch to the requirements, using library code (and creating such libraries, growing your algorithmic repertoire), not pieces of application. Software reuse means developing and using libraries, not copy-and-paste.

Let me tell you that there is no principal difference between one or more grid views. If you see a problem in "converting" single grid view code into multiple, you just don''t even try to do any professional chores. Besides, you should understand that there is no such thing as "just XML" which you can write. There are different data models which can be created to different application, and their structures can be expressed as some meta-data, which corresponds to one or another XML schema. The same application data representation can be modeled in a number of different ways giving different schemes.

Besides, it''s possible that the code samples you saw were not good. You should not have code saving some UI state in XML file, not when UI expresses some data set. Instead, you need to isolate UI from data model, and data model from persistence. In the simplest case, you can have an instance of a data model in memory and have procedures for populating UI from data, and modifying data from UI state. And the data, not UI, should be uses for persistence. Everything is already done for you, as you can use Data Contract which will allow you to avoid dealing with XML directly. Please see:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

Please also see my past answers where I advocate this approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].

—SA


对不起,但是如果我想要一个现成的示例,我会购买软件程序.相反,我正在尝试学习它,实际上已经退出了很多东西,但这让我感到困惑.

很抱歉浪费您的时间,但是请再说一次,不要回应!
Sorry, but if I would like an of-the-shelf example I would shop for a software program. Instead, i''m trying to learn it and actually already for quit a lot, but this ones keeps me puzzling.

Sorry for waisting your time, but then again, DO NOT RESPOND!!


这篇关于将多个Datagridview导出到1个xml vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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