表单未在设计视图VS 2012中显示 [英] Form not displayed in design view VS 2012

查看:83
本文介绍了表单未在设计视图VS 2012中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2012中有一个项目。这是一个Windows窗体项目。突然,当我在设计视图中查看时,表单不显示任何控件。但是当我运行程序时,我确实看到了表单和所有控件。为什么会这样?请注意,这个项目是在同一个Visual Studio 2012中制作的。我怎样才能克服这个问题?请指教。

I have a project in Visual Studio 2012. This is a windows forms project. Suddenly the form doesn't show any controls when I view it in design view. But when I run the program, I do see the form and all the controls. Why is this happening? Please note that this project was made in the same Visual studio 2012. How can I overcome this? Please advice.

推荐答案

您没有显示任何代码,因此没有人可以指出错误的位置。但是,我可以就你的工作向你提供建议。



这种情况​​非常典型:你的一些代码在执行时会引发异常设计师,由一个或另一个原因。您可以同时使用一种简单的技术用于两个目的:1)确定问题,2)避免它。查看属性 System.Windows.Forms.Control.DesignMode

http://msdn.microsoft.com/en-us/library/system.windows.forms.control%28v = vs.110%29.aspx [ ^ ]。



开始将代码段放在if块下,例如

You did not show any code, so no one can point out where the bug is. However, I can give you the advice on what you do.

The situation is pretty typical: some piece of your code can throw an exception when it is executed by a designer, by one or another reason. You can use one simple technique for two purposes at the same time: 1) to pin-point the problem, 2) to avoid it. Look at the property System.Windows.Forms.Control.DesignMode:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control%28v=vs.110%29.aspx[^].

Start putting the pieces of your code under the "if" block, such as
if (!myControl.DesingMode)
{
   // your existing code
}

// ...

if (!myForm.DesingMode)
{
   // your existing code
}

// ...



添加此项检查不会修改在执行应用程序期间的行为,它不会被破坏。同时,一些导致设计问题的代码将从执行中消除。这只是一个想法,但在这种情况下它非常有效。



-SA


这篇关于表单未在设计视图VS 2012中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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