How to stop visual studio from opening my winforms controls in the designer

爷,独闯天下 提交于 2019-12-04 19:27:07

问题


When I want to edit/view the code for a winforms control/form i created, I need to right-click in the solution and select "view code". The default action for opening the file is "view designer". This appears to be the case for any C# file containing a class that inherits from a winforms control, even if this is indirectly.

The daft thing is that VS does this if it can't run the designer (for instance when the control is not the first class in the file).

Is there hint or attribute or workaround to stop VS from doing this?


回答1:


  • Right-click on a file in your solution
  • Select "Open With..."
  • Select "CSharp Editor"
  • Click "Set as Default".
    (In a web application, you need to select "Web Form Editor")



回答2:


Decrotate your Form or Control that should open in code view with [System.ComponentModel.DesignerCategory("Code")]



来源:https://stackoverflow.com/questions/3870990/how-to-stop-visual-studio-from-opening-my-winforms-controls-in-the-designer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!