简体   繁体   English

Winforms usercontrol现象:突然所有物品都消失了!

[英]Winforms usercontrol phenomenon : suddenly all items are away!

I have a winform usercontrol with several items (textboxes, buttons,...). 我有一个winform usercontrol与几个项目(文本框,按钮,...)。 Now I am confronted with phenomenon , that all items are suddenly away (in the VS 2010 designer view / document outline), although in the control designer file ( designer.cs ) the textboxes, buttons,... are still defined. 现在我遇到的现象是 ,所有项目都突然消失(在VS 2010设计器视图/文档大纲中),尽管在控件设计器文件( designer.cs )中仍然定义了文本框,按钮...... There is also no compilation error. 也没有编译错误。 When I run the application, the items are still missing! 当我运行应用程序时,项目仍然缺失! I have already restarted VS! 我已经重启了VS! Does anybody know, what the reason for this is? 有谁知道,这是什么原因?

In the InitializeComponent method do all the controls get added to the form via this.Controls.Add... statements? 在InitializeComponent方法中,通过this.Controls.Add ...语句将所有控件添加到表单中吗?

I know this happened with VS2003 a lot that these code lines would disappear. 我知道VS2003发生了很多事情,这些代码行会消失。 I suspect that this is the problem 我怀疑这是问题所在

  1. Did you possibly remove the call to InitializeComponent from your control's constructor by accident? 您是否可能意外地从控件的构造函数中删除了对InitializeComponent的调用?

  2. Does the name of the partial class in your .designer.cs file match that of your "main" control file? .designer.cs文件中的分部partial class名称是否与“主”控制文件的名称相匹配?

  3. Try running your application through VS's debugger. 尝试通过VS的调试器运行您的应用程序。 Put a breakpoint at InitializeComponent and step through all the code responsible for creating and placing all the controls in your user control. InitializeComponent放置一个断点,并逐步执行所有负责创建和放置用户控件中所有控件的代码。 Maybe you will happen upon an explanation this way. 也许你会以这种方式解释。

尝试重新启动Visual Studio,然后执行重建解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM