如何使用类文件在Windows应用程序的内存中存储表单数据 [英] How to Store Form Data in Memory in windows application using class file

查看:69
本文介绍了如何使用类文件在Windows应用程序的内存中存储表单数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建Windows应用程序,其中有两种形式employee_details和communication_details.i不使用databse.在员工详细信息"表单中,单击下一步"按钮后填写员工详细信息,然后转到"communication_details"表单,然后单击填充",然后填写员工通信数据.保存的数据必须保存在内存中.将数据存储在内存中,但这是错误的.

i am creating windows application in which i have two forms employee_details and communication_details.i do not use databse. In Employee details form fill up employee details after that i clicked on next button it goes to communication_details form and fill up employee communication data after that i clicked on saved the data must be saved on memory.i am taking too much variable in class file to store data in memory but which is wrong.

推荐答案

问题不明确,看起来很幼稚.您正在尝试找到针对特定应用程序的方法来解决一个非常普遍的问题(但无论如何都无法提供足够的信息).

尝试从以下方向思考:为什么需要将表单数据保存在内存中?形式本身并不需要,它起着某种应用程序语义的顺从作用,仅用于UI表示和控件;使用该表格,用户可以查看数据并表达有关如何修改数据的决定.

因此,首先,您需要将数据与UI呈现隔离开来.您需要有一些保留在内存中的数据模型(就您而言;假设您就在这里,我不会分析它的内存表示的适用性)并且可以以一种或另一种方式持久化(并非总是如此,但是否则您的应用程序将无法创建或使用任何数据工件).数据模型(您的员工及其关系,通信)不应依赖于UI.然后,您将需要以某种方式将此数据与UI绑定.在一个简单的情况下,您应该有一种使用数据模型填充表单的方法,以及一种根据UI控件的状态更新数据模型的方法.

您需要检查您的设计并从这里开始.我建议您学习和分析以下建筑模式( http://zh-CN)的适用性. wikipedia.org/wiki/Architectural_pattern_(computer_science) [^ ]):

MVVM —模型视图视图模型,
http://en.wikipedia.org/wiki/Model_View_ViewModel [> http://en.wikipedia.org/wiki/Model-view-controller [ ^ ])),

MVA —模型视图适配器,
http://en.wikipedia.org/wiki/Model–view–adapter [ ^ ],

MVP —模型视图呈现器,
> http://en.wikipedia.org/wiki/Model-view-presenter [ ^ ].
请注意这些架构的动机.如果您了解它,就可以提出更好的设计思路.

—SA
The question is unclear and looks naive. You are trying to find an application-specific approach to a very general problem (but anyway don''t provide enough information).

Try to think in the following direction: why would you need to save form data, in memory or not? A form is needed not for itself, it plays a role submissive to the semantic of some application, is used just a UI presentation and control; using the form, the user look at data and express the decisions on how to modify the data.

So, first of all, you need to isolate the data from the UI presentation of it. You need to have some data model which stays in memory (in your case; I''m not analyzing applicability of the memory presentation of it, assuming that you are right here) and can persist in one or another way (not always, but otherwise your application could not create or use any data artifacts). The data model (your employees and there relations, communications) should not depend on the UI. Then, you will need to bind this data with your UI somehow. In a simple case, you should have a method of populating the form(s) with data model and a method for updating the data model according to the state of your UI controls.

You need to review your design and start from here. I would suggest you learn and analyze applicability of the following architectural patterns (http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)[^]):

MVVM — Model View View Model,
http://en.wikipedia.org/wiki/Model_View_ViewModel[^],

MVC — Model-View-Controller,
http://en.wikipedia.org/wiki/Model-view-controller[^]),

MVA — Model-View-Adapter,
http://en.wikipedia.org/wiki/Model–view–adapter[^],

MVP — Model-View-Presenter,
http://en.wikipedia.org/wiki/Model-view-presenter[^].
Pay attention for the motivation of those architectures. If you understand it, you would be able to create better design ideas.

—SA


这篇关于如何使用类文件在Windows应用程序的内存中存储表单数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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