我从另一个表单创建了Button但是当我重新打开app时,所有控件都消失了 [英] I created Button from another form but when i reopen app all controll disappear

查看:91
本文介绍了我从另一个表单创建了Button但是当我重新打开app时,所有控件都消失了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在主窗体上从另一个窗体创建了Button,如编程方式Button btn = new Button();  。但是当我重新打开应用程序时,所有控件都会消失或丢失。是什么原因?

I created Button on the main form from another form like programmatically Button btn = new Button() ;  .But when i reopen app, all controll disappear or lose. what is the reason ?

谢谢。

推荐答案

这不像你拖了一个按钮到窗体上可用的控件的窗体,使控件在窗体上成为永久控件。您从另一个表单动态创建控件。它不是你为
其他形式创建的永久控件。  您创建的控件是动态的,这意味着必须运行代码才能创建动态控件。程序停止运行,动态/程序创建的控件将丢失。
It is not like you dragged a button to the form from the controls that are available on the form that makes the control permanent on the form. You dynamically created the control from another form. It's not a permanent control you have created for the other form.  The control you created is dynamic, which means that code must be ran to create the dynamic control. The program stops running and the dynamic/programmically created control is lost.


这篇关于我从另一个表单创建了Button但是当我重新打开app时,所有控件都消失了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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