vb.net main.vb、main.designer.vb 和缺少的表单设计器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22286349/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
main.vb, main.designer.vb and missing Form Designer
提问by
I have been working with "visual basic.net" on a "windows forms" application. While manipulating controls and adding event handlers I noticed the resultant code was being generated within a file named 'main.designer.vb'. However, if I look in the solution explorer for my project there is no 'main.designer.vb' file, just 'main.vb'.
我一直在“windows 窗体”应用程序上使用“visual basic.net”。在操作控件和添加事件处理程序时,我注意到生成的代码是在名为“main.designer.vb”的文件中生成的。但是,如果我查看我的项目的解决方案资源管理器,则没有“main.designer.vb”文件,只有“main.vb”。
This is not a colossal problem as it runs properly. However, having closed the 'form designer' window I now cannot reopen it! 'main.vb' has no option to 'view in form designer'.
这不是一个大问题,因为它运行正常。但是,关闭了“表单设计器”窗口后,我现在无法重新打开它!“main.vb”没有“在表单设计器中查看”的选项。
Any advice on this?
对此有何建议?
Would it be possible to copy the contents of 'main.designer.vb' in to 'main.vb' and delete 'main.designer.vb' entirely? If I did this, the next time I manipulated the form would the code be added to 'main.vb' or would a new 'main.designer.vb' be created?
是否可以将“main.designer.vb”的内容复制到“main.vb”并完全删除“main.designer.vb”?如果我这样做了,下次我操作表单时,代码会被添加到“main.vb”中,还是会创建一个新的“main.designer.vb”?
回答by
I seem to have sorted out the problem.
我似乎已经解决了问题。
'main.vb' was completely empty. All the code I had generated and written directly was inside 'main.designer.vb'. However, once I made a class definition within 'main.vb':
'main.vb' 完全是空的。我直接生成和编写的所有代码都在“main.designer.vb”中。但是,一旦我在 'main.vb' 中做了一个类定义:
Public Class main
End Class
and then cut/pasted all my custom event handler code and subroutines from 'main.designer.vb' to THAT class - all was well. 'main.vb' now shows the correct form icon and FINALLY offers the correct 'view designer' context menu option.
然后将我所有的自定义事件处理程序代码和子程序从“main.designer.vb”剪切/粘贴到那个类 - 一切都很好。“main.vb”现在显示正确的表单图标,最终提供正确的“视图设计器”上下文菜单选项。
I am not sure why it happened in the first place though.
我不确定为什么它首先发生。
回答by Jens
Look in the Solution Explorer in Visual Studio. In the toolbar in this window is a button called "Show all files". Click it. Then every file in the projects folder is actually shown in the solution explorer. Expand the treenodes for the form and you will see the designer.vb.
查看 Visual Studio 中的解决方案资源管理器。在此窗口的工具栏中有一个名为“显示所有文件”的按钮。点击它。然后项目文件夹中的每个文件实际上都显示在解决方案资源管理器中。展开窗体的树节点,您将看到 Designer.vb。
There are also buttons for switching between code-view and designer view. Just remember to select the form in the solution explorer for the buttons to show the correct form in the designer.
还有用于在代码视图和设计器视图之间切换的按钮。请记住在解决方案资源管理器中为按钮选择表单以在设计器中显示正确的表单。

