WinForms中的ViewState [英] Viewstate in winforms

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

问题描述

大家好

Windows应用程序中是否有任何视图状态?

实际上,我希望重新初始化面板之前面板中存在控件.
在我的项目中,我每10秒动态创建一个面板.
所以我写了

Hi all

Is there any view state in Windows application???

Actually i want the controls present in a panel before reinitialize the panel.
In my project i have create a panel in every 10 second dynamically.
So i wrote that

Panel pnlTest = new Panel();


在滴答声事件中.
每隔10秒,面板控件就会消失,因为面板每隔10秒就会初始化.

但是我想要那个面板的控件.

所以想要一个View状态类型的东西.

请建议

在此先谢谢.


in the tick event.
After every 10 second the panels controls disappear because the panel is initializing after every 10 second.

But i want the that panel''s controls.

So want a View state type thing .

Please suggest

Thanks In advance.

推荐答案

真是胡扯!由于HTTP协议的无状态性,很难理解View State是Web应用程序非常不常见的情况的产物吗?
请参阅:
http://en.wikipedia.org/wiki/View_State#State_management [ http://msdn.microsoft.com/en-us/library/ms972976.aspx [ ^ ].

对于普通"应用程序,视图状态的想法几乎相同,就像在每次单击控件(或每10秒:-)时重新加载整个UI桌面应用程序,然后还原状态机的整个状态一样.对于普通的桌面应用程序开发人员来说,这听起来似乎很疯狂,但这实际上是Web应用程序发生的情况(如果我们暂时忘记了客户端脚本和Ajax).在桌面应用程序上应用相同的思想是……嗯,我什至不知道该怎么建议,也许从一开始就开始学习编程.

同时,当整个应用程序关闭然后再次启动时,保存和恢复应用程序的状态确实是一件好事,但这是完全不同的事情.在所有情况下,当涉及到桌面应用程序时,您都应该忘记将查看状态"视为噩梦.但是,对于希望如此迅速地用面板淹没应用程序的人来说,所有事情都可能发生.甚至不用理会原因……:-)

—SA
What an abuse and nonsense! Is it so hard to understand that the View State is the artifact of quite unusual situation with Web applications, due to the stateless nature of HTTP protocol?
Please see:
http://en.wikipedia.org/wiki/View_State#State_management[^],
http://msdn.microsoft.com/en-us/library/ms972976.aspx[^].

For "normal" application thinking of a View State is nearly the same, as re-loading the whole UI desktop application on every control click (or every 10 seconds :-)) and then restoring the whole state of the state machine. For a normal desktop application developer, it would sound totally wild, but this is what actually happens with Web applications (if we forget about client-side scripting and Ajax for a moment). Applying the same thinking to desktop application is something which… well, I don''t even know what to advise, perhaps starting to learn programming from the very beginning.

At the same time, saving and restoring of the status of the application when the whole application is closed and then started again is a really good thing, but this is a very different story. In all cases, you should forget the idea of View State as a nightmare, when it comes to desktop applications. However, everything can happen to a person who wish to overwhelm the application with panels so quickly. Don''t even bother to explain why… :-)

—SA


这可能对您有帮助

保存状态(序列化)Windows窗体 [ ^ ]
This may help you

Saving the state (serializing) a Windows Form[^]


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

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