简体   繁体   English

表单在解决方案资源管理器中显示为类

[英]Form showing as a class in Solution Explorer

I have a form in my project that is showing up as a class in Solution Explorer. 我的项目中有一个表单显示为解决方案资源管理器中的类。 This is causing a problem since I can't get to the designer. 因为我无法联系设计师,所以这引起了一个问题。 Any ideas on how to fix this? 有想法该怎么解决这个吗?

You can fix the problem manually by editing your csproj file. 您可以通过编辑csproj文件来手动解决问题。

Open it in notepad and search for the filename of the class. 在记事本中打开它,然后搜索类的文件名。 You should see something like this... 你应该看到这样的东西...

<Compile Include="frmTest.cs" />

Add a subtype called 'Form' like this... 像这样添加一个名为“ Form”的子类型...

<Compile Include="frmTest.cs">
    <SubType>Form</SubType>
</Compile>

Reload the project. 重新加载项目。 Visual Studio should now identify the file correctly. 现在,Visual Studio应该可以正确识别文件。

删除与窗体相关的dll的引用,然后再次添加并构建项目

Try seeing if there are any hidden files by using the the 'Show All Files' button. 尝试使用“显示所有文件”按钮查看是否存在任何隐藏文件。 Sounds like your project file might not have all of the files added to it. 听起来您的项目文件可能没有将所有文件都添加到其中。

One thing that has worked for me in the past is to just add another blank form to the project and that seemed to make the other form show up as a form. 过去对我有用的一件事是仅向项目添加另一个空白表单,这似乎使另一个表单显示为表单。 You can then delete the blank form. 然后,您可以删除空白表格。

I don't know if it will work for you, but it only takes a few moments to try it. 我不知道它是否对您有用,但是只需花一点时间即可尝试。

Chris 克里斯

Simply select the form and press Shift+F7. 只需选择表格,然后按Shift + F7。 You'll find your form. 您会找到自己的表格。

Press F7 when in code editor to get to the designer. 在代码编辑器中时,按F7键可进入设计器。 And restarting Visual Studio usually helps. 重新启动Visual Studio通常会有所帮助。

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

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