加载在其控件上应用了更改的表单 [英] load a form with changes applied on its controls

查看:143
本文介绍了加载在其控件上应用了更改的表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


假设我们有一个带有不同控件的表单.假设有一个文本框和一个chkbox.如果用户键入内容并更改检查状态,那么我希望通过关闭表单并再次打开它,可以在关闭之前查看表单的状态(而不是设计状态).我需要在带有约50个不同控件的表单上实施.您能给我一个提示吗?

我需要的是以某种方式保存表格.由于我需要为用户提供以下选项之一:1.创建新2.编辑现有.表格实际上获得了运行模拟的调整,因此很难每次都调整首选项.将来还应该加载不同的调整.

Hi,
Suppose that we have a form with different controls. let say a textbox and a chkbox. If a user types something and change check status, I would like that by closing the form and opening it again, I''ll be able to see the status of the form just before closing(not the designed status). I need this to implement on a form with around 50 different controls. Would you please give me a hint for that?

what I need is somehow save the form. Since I need to get the user one of the following options: 1. Create New 2. Edit Existing. The Form actually gets the adjustments for running a simulation, so its difficult to adjust the preferences every time. Also different adjustments should be loadable in future.

推荐答案

好的,因此您需要存储值...有两种主要的实现方法.

1.数据库
-----------------------
如果您有数据库,则只需创建一个带有字段的表即可保存表单关闭时的控件值,然后只需在表单以编辑模式"打开时从数据库中加载这些值并适当地设置控件即可.

2.文件系统
-----------------------
更基本的做法是将值保存到文件中.您可以简单地创建一个文本文件并在窗体关闭时编写控制值,或者如果您想有点疯狂,可以创建一个serializabe类来保存窗体控制值...然后可以将值写入/读取到/来自XML文件.

如果您需要任何用于存储值的方法的帮助,您可能想问一个有关您已经使用的代码遇到的特定问题的新问题,以便人们可以看到您尝试过的内容.

祝您好运!
Okay, so you need to store your values... there are two main ways of doing this.

1. Database
-----------------------
If you have a database, you simply create a table with fields to hold the control values at the time the form closes, then you simply load those values from the database when the form opens in ''edit mode'' and set the controls appropriately.

2. File System
-----------------------
A little more basic would be saving the values to a file. You can either simply create a text file and write the control values on form close, or if you would like to get a bit wild, create a serializabe class to hold the forms control values... then your values can be written/read to/from a XML file.

If you need help with any method for storing values, you will probably want to ask a new question about a specific problem you are having with the code you have already done so folks can see what you''ve tried.

Good luck!


您需要为表单创建一个有限状态机(FSM).没有复杂性:您应该用状态来描述一切.例如,如果触发了一些计算,结果将流向何方?它应该反映在表单的某些数据成员中.等等.因此,从状态机的角度分析每种表单开始,不要考虑保留现有的表单功能.根据模型设计表单,而不是其他方式.完成此操作后,请执行两个操作:存储FSM和加载FSM,以便在表单中填充数据.

参见 http://en.wikipedia.org/wiki/Finite-state_machine [枚举类型不枚举!解决.NET和语言限制 [ ^ ],请参阅"3.6直角坐标系"一章.

—SA
You need to create a Finite-State Machine (FSM) for your form. There are no complication: you should describe everything in term of states. For example, if some calculations are triggered, where the result go? It should be reflected in some data members of the form. And so on. So, start with the analysis of each form in terms of state machine, don''t think of preserving existing form functionality. Design form based on the model, not the other way around. When this is done, implement two operations: storing FSM and loading FSM, so the form would be populated with the data.

See http://en.wikipedia.org/wiki/Finite-state_machine[^].

FSM itself can be implemented based on enumeration type. Given a set of states, a FSM can be represented as a sub-set of the Cartesian square of this set, each element of the sub-set representing an allowed transition. I developed a generic class which implements the data indexed by the elements of Cartesian square build over the arbitrary enumeration type, so the formal mechanism is read. Please see my article Enumeration Types do not Enumerate! Working around .NET and Language Limitations[^], see the chapter "3.6 Cartesian Square".

—SA


这篇关于加载在其控件上应用了更改的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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