Visual Studio未检测到某些用户控件和窗体,导致我无法打开该控件设计器

Visual Studio not detect some User Controls and Forms cause me can not open that control designer

提问人:Maguro 提问时间:11/7/2023 更新时间:11/7/2023 访问量:28

问:

我发现一些用户控件和窗体显示为纯代码。它仍然显示 .设计器 .cs 和 .resx,但没有打开设计器的选项。任何建议请

  • 这些控件可以在以前打开设计器
  • VS 2022 社区
  • 二手 .NET Core 6

谢谢。

enter image description here

enter image description here

C# .NET Windows WinForms

评论


答:

0赞 Maguro 11/7/2023 #1

我自己刚刚找到了解决方案。问题窗体和控件未在项目文件中定义。只需添加以下代码,然后重新加载项目

<Compile Update="YourForm.cs">
    <SubType>Form</SubType>
</Compile>

<Compile Update="YourUC.cs">
    <SubType>UserControl</SubType>
</Compile>

评论

0赞 Voidsay 11/7/2023
请将您自己的答案标记为解决方案,以便问题得到解决。