简体   繁体   English

Visual Studio 窗口中的所有控件在加载时都不可见

[英]All the controls in visual studio windows form invisible while loading it

In Visual Studio 2010 , while loading a visual c# form, the form comes up, but all the controls in it, and everything has become invisible.在Visual Studio 2010中,在加载一个visual c#窗体时,窗体出现了,但是里面的所有控件,一切都变得不可见了。

I'm getting the following error:我收到以下错误:

Warning 1 'EIM.Form2.Name' hides inherited member 'System.Windows.Forms.Control.Name'.警告 1 'EIM.Form2.Name' 隐藏继承的成员 'System.Windows.Forms.Control.Name'。 Use the new keyword if hiding was intended.如果打算隐藏,请使用 new 关键字。 C:\\Users\\Administrator\\documents\\visual studio 2010\\Projects\\EIM\\EIM\\Form2.Designer.cs 1172 44 EIM C:\\Users\\Administrator\\documents\\visual studio 2010\\Projects\\EIM\\EIM\\Form2.Designer.cs 1172 44 EIM

Can anyone point me in the right direction?任何人都可以指出我正确的方向吗?

It's because the base members are not being called.这是因为没有调用基本成员 When you declare a Name property in your derivative class, you hide the Name member for your base class.当您在派生类中声明Name属性时,您隐藏了基类的Name成员。 Therefore, when your form is compiled, your derivative will be called rather than the base, and your controls become "invisible".因此,当您的表单被编译时,您的派生将被调用而不是基数,并且您的控件将变得“不可见”。

In addition to what aevitas said I guess the problem only occurs while the form is loading ?除了 aevitas 所说的,我猜问题只发生在加载表单时? One reason could be that you're performing some long-lasting action in the Load event of the form.一个原因可能是您在窗体的Load事件中执行了一些持久的操作。 This causes the form to be shown, but everything is either invisible or unusable.这会导致显示表单,但所有内容要么不可见,要么无法使用。

Try putting the code that performs this long-lasting operation into the Shown event, which is called after the form was shown and all controls were initialized.尝试将执行此持久操作的代码放入Shown事件中,该事件在Shown窗体并初始化所有控件调用。

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

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