文字框显示 [英] Textbox display

查看:71
本文介绍了文字框显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..
我有一个DatetimepickerAmount Textbox和一个Total amount文本框(用于当前日期),其名称为Deposit ..

假设,
(首次ExecutionSmile
如果我选择今天的日期并在Amount文本框中输入金额(例如4000),则在Total amount文本框中(对于当前日期),它应连续显示相应的金额(4000)...之后那
(在第二次ExecutionSmile期间
如果我在金额文本框中选择了(今天)日期和第二个金额(例如4000),则在总计金额"文本框中(对于当前日期),它应该显示该金额,该金额是前一个金额的总和(8000)连续.

谁能帮我解决编码问题...

[针对可读性进行了编辑]

Hi..
I am having a Datetimepicker, Amount Textbox and a Total amount textbox (for a Current date) in a form named Deposit..

In that Suppose,
(For a First Time ExecutionSmile
if I select today''s date and enter the amount in Amount textbox (say 4000), then in the Total amount textbox (for a Current date) it should display the respective amount(4000) consecutively...and after that
(During Second Time ExecutionSmile
if I select The (same)today''s date and the second amount in the amount textbox(say 4000),then in the Total amount textbox (for a Current date) it should display the amount which is the addition of the previous amount(8000) consecutively.

can anyone please help me to solve this problem with coding...

[edited for readability]

推荐答案

保持班级中的运行总计,并在每次更改金额时更新总计文本框;这是相当基本的C#.如果您需要保持程序执行之间的运行总数(假设这就是Second Time ExecutionSmile的意思),则需要通过一些数据文件或属性将值持久保存到永久存储中.
Keep the running total in your class and update the total amount textbox every time you change the amount; this is fairly basic C#. If you need to keep the running total between executions of your program (assuming that''s what you mean by Second Time ExecutionSmile) then you need to persist the value to permanent storage via some data file or properties.


因此,您将需要存储两条信息:
1)日期
2)总计
输入新金额时,请检查日期是否已经有总计,如果有,则添加新值.否则,创建新日期,并将total设置为新值.

存储信息的方式因您的应用程序而异:
如果不需要总计是永久性的(即,每次启动应用程序时都从头开始),则可以使用DateTime键将它们存储在类级别的Dictionary中(请记住将时间设置为午夜!)

如果需要持久性,那么根据可用的内容,您将有很多选择:
XML文件,
序列化类,
数据库(Access,SQLCE,MSSql,MySql等-取决于可用的资源).
So, you are going to need to store two pieces of information:
1) Date
2) Total
When you enter a new amount, check if the date has a total already, and if it does, add the new value in. Otherwise, create a new date, and set teh total to the new value.

How you store the information will vary according you your app:
If you do not need totals to be persistent (i.e. you start from scratch each time you start the app) then store them in a class level Dictionary, with a DateTime key (remember to set the time to midnight!)

If you need persistence, then you will have lots of choices depending what you have available:
XML files,
Serialized class,
Database (Access, SQLCE, MSSql, MySql, etc. - depends on what you have available).


这篇关于文字框显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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