VisualStudio 2017 C# Isolates Normal Code from Designer

Asked 2 years ago, Updated 2 years ago, 42 views

Thank you for your help.

In Win10, while writing the code for C# in VScommunity, you can
code the form from another project. When you copy it, for some reason, the normal code and the Designer code are separated on the tree.br/> It will be displayed.Even if you open the copied form in the design,
Only the initial empty form is displayed, and you cannot edit it later.

This is not the first time this has happened, but it has happened several times in the past. Erase resx and restart VS, erase the entire 'obj' folder in the folder
I felt that it was solved by restarting VS, but this time it was also
It didn't come back.

In the first place, this phenomenon does not happen every time, and sometimes it works without any problems. I don't know the cause or countermeasure.

Could you tell me the solution?

Thank you for your cooperation.

Enter a description of the image here

c# visual-studio

2022-09-29 21:51

1 Answers

Perhaps the information in the following article applies.
Here are excerpts of what might be relevant, but read the rest of the answers in this article as well.

However, be aware that the VisualStudio at the time of the question is out of date, so the extension may have changed and the XML item name may have changed.

Also note that basically namespace, class name/attribute definitions, controls used in copied code are declared variables, and that { and }·( and ) are balanced.

Form and designer files not linking in Solution Explorer
Answers marked with resolution in this article are:

I saw the same problem in Visual Studio 2008.Typically, compiling or closing the solution and reopening it will solve the problem.In Visual Studio 2012, you can see the problem if you select Add > Existing Items and select all three files.Typically, you just need to add the top-level form.cs, and the VS will automatically include the .designer.cs and .resx files.

Would this answer be more useful?(The quote highlighted the $$$ Check this below)

Review Project (.csproj)

<EmbeddedResourceInclude="Properties\Resources.resx">
  <Generator>ResXFileCodeGenerator</Generator>$$$Check this
  <SubType>Designer</SubType>
  <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>

<Compile Include="Properties\Resources.Designer.cs">
  <AutoGen>True</AutoGen>$$$ Check this
  <DesignTime>True</DesignTime>
  <DependentUpon>Resources.resx</DependentUpon>
</Compile>

Unable to get the designer view window back using windows forms with Visual Studio 2010

Make sure that the class is not declared before the designer partial class.cs file must have the partial designer class as the first class of the file.

public partial class frmWidget:Form
{
}

public class SomeClass
{
}

SomeClass cannot be over a partial frmWidget class. Relocation automatically fixes the designer's problems, so you do not need to restart the VS or recreate the form. I hope this will help.

Visual studio solution explorer not showing forms cs file

I had the same problem and the form was not displayed.
What you should do is

    Edit the
  • project file /project_directory/project_name.csproj to verify that your_form_name.cs is:
    Note: Delete all existing records with your_form_name.cs from the project file first, then add the following:
<Compile Include="your_form_name.cs">
   <SubType>Form</SubType>
</Compile>
<Compile Include="your_form_name.Designer.cs">
   <DependentUpon>your_form_name.cs</DependentUpon>
</Compile>
   <EmbeddedResourceInclude="your_form_name.resx">
   <DependentUpon>your_form_name.cs</DependentUpon>
</EmbeddedResource>

Open the solution again and the Form will appear in the project again.

The last part above probably corresponds to the Group Files below.
Check out Microsoft Docs sites.

Make Visual Studio More Convenient with Extensions

Solution Explorer Extensions
 Add commands that you can run on Solution Explorer, such as:
Group Files
 You can group and ungroup multiple files.Visual Studio's basic functionality, for example, is designed to make it easy for Windows form applications to use the functionality used to group form designers' Form1.designer.cs files and isolation code Form1.cs files.This feature allows you to manage files of the same class, divided into multiple files, using subclasses and so on.


2022-09-29 21:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.