English 中文(简体)
我如何能够在窗口申请中增加关于形式负荷的方框内容
原标题:How can I increment a textbox content on form load in windows application
  • 时间:2011-08-04 10:27:27
  •  标签:
  • c#
  • winforms

如何在形式装货上加固一个文本箱的内容,这样一来,如果我提出申请,如果形式正在装上价值,则该数值应为千瓦1,如果通过结束我的申请而重载同一表格,则应为千卡2。

问题回答

You can write the value into somewhere other than RAM. For example:

  • Registry
  • Files(XML or plain text)
  • Database
  • Application settings

将数值推入静变数不会奏效,因为在申请结束时,记忆是免费的,因此变数的价值将予以消除。

您可以通过数据库或应用环境来做到这一点。

你现在只谈论一个领域,如果你认为今后将有更多的领域像现在这样行事,或者你拥有一个数据库供你应用,那么我会与数据库联系。

在形式闭幕式中,将文字箱的最后价值储存在一个静态变量中。

Implement the form load event, retrieve the value from the static variable and populate the text box with it.

I think the simplest way would be to save the value (in your case QS0001 or whatever) to an xml file. And then the next time when you reload the form read that value to a variable,then perform incrementation process by getting the numerical part and adding 1 to it and then reattaching the resultant value.





相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签