我正在尝试在 Visual Studio 中使用 C# 创建 Windows 窗体应用程序。
一般情况下可以双击Form1.cs
在解决方案资源管理器中双击该文件,以访问简单的拖放设计器。
不幸的是,它只打开文件的代码。
在表单类之前放置另一个类(在本例中是我的ImageContainer
类)时遇到同样的问题。
namespace ImageProcessor
{
internal class ImageContainer
{
}
public partial class Form1 : Form
{
private ImageContainer m_img = null;
}
}
Run Code Online (Sandbox Code Playgroud)
只需将VS2019 拖放设计器移动internal class ImageContainer
到后面即可加载我的 Form1 类。public partial class Form1 : Form { }
namespace ImageProcessor
{
public partial class Form1 : Form
{
private ImageContainer m_img = null;
}
internal class ImageContainer
{
}
}
Run Code Online (Sandbox Code Playgroud)
解决方案资源管理器中的符号也更改回对话框图标。
文件之间的关联肯定以某种方式被破坏了。您可以手动编辑 .csproj 文件并更正它。搜索Form1
。每个文件都应该有如下所示的条目:
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
Run Code Online (Sandbox Code Playgroud)
注意SubType
和DependentUpon
。这些是重要的部分。
归档时间: |
|
查看次数: |
41452 次 |
最近记录: |