partial classes in Solution explorer
-
In solution explorer, I noticed that the Form1.Designer partial class is listed under the Form1.cs I created some other partial class(Myclass.cs) of From1 but it doesn't appear under the Form1 in solution explorer. Is there anyway I can get it to appear under Form1. Currently -Form1.cs | ----->Form1.Designer.cs | ----->Form1.resx ... ... MyClass.cs Looking for -Form1.cs | ----->Form1.Designer.cs | ----->Form1.resx | ----->MyClass.cs .....
-
In solution explorer, I noticed that the Form1.Designer partial class is listed under the Form1.cs I created some other partial class(Myclass.cs) of From1 but it doesn't appear under the Form1 in solution explorer. Is there anyway I can get it to appear under Form1. Currently -Form1.cs | ----->Form1.Designer.cs | ----->Form1.resx ... ... MyClass.cs Looking for -Form1.cs | ----->Form1.Designer.cs | ----->Form1.resx | ----->MyClass.cs .....
Try prepending Form1 to MyClass.cs. The solution explorer tries to logically put everything together by their file name. If you write Form1.MyClass.cs, VS should see that file as a subset of your Form1 and show it in the tree as such.
-
In solution explorer, I noticed that the Form1.Designer partial class is listed under the Form1.cs I created some other partial class(Myclass.cs) of From1 but it doesn't appear under the Form1 in solution explorer. Is there anyway I can get it to appear under Form1. Currently -Form1.cs | ----->Form1.Designer.cs | ----->Form1.resx ... ... MyClass.cs Looking for -Form1.cs | ----->Form1.Designer.cs | ----->Form1.resx | ----->MyClass.cs .....
There's no way to do this automatically in VS but you can do this:
- Right click the project in the Solution Explorer and select Unload Project.
- Right click the project again in the Solution Explorer and select Edit
Project.csproj
- Look for an XML element which is like
<Compile Include="MyClass.cs" />
and change it to:<Compile Include="MyClass.cs"><DependentUpon>Form1.cs</DependentUpon></Compile>
Close the project file in the editor and reload the project like in step 1, your file should now appear under the Form1 node. Note you could specify
Form1.Designer.cs
and it'd be displayed under that one instead. -
Try prepending Form1 to MyClass.cs. The solution explorer tries to logically put everything together by their file name. If you write Form1.MyClass.cs, VS should see that file as a subset of your Form1 and show it in the tree as such.
-
There's no way to do this automatically in VS but you can do this:
- Right click the project in the Solution Explorer and select Unload Project.
- Right click the project again in the Solution Explorer and select Edit
Project.csproj
- Look for an XML element which is like
<Compile Include="MyClass.cs" />
and change it to:<Compile Include="MyClass.cs"><DependentUpon>Form1.cs</DependentUpon></Compile>
Close the project file in the editor and reload the project like in step 1, your file should now appear under the Form1 node. Note you could specify
Form1.Designer.cs
and it'd be displayed under that one instead.I just saw myself after digging into the project file, when I couldn't repeat what I was talking about. Thank you for showing my ineptitude!
-
There's no way to do this automatically in VS but you can do this:
- Right click the project in the Solution Explorer and select Unload Project.
- Right click the project again in the Solution Explorer and select Edit
Project.csproj
- Look for an XML element which is like
<Compile Include="MyClass.cs" />
and change it to:<Compile Include="MyClass.cs"><DependentUpon>Form1.cs</DependentUpon></Compile>
Close the project file in the editor and reload the project like in step 1, your file should now appear under the Form1 node. Note you could specify
Form1.Designer.cs
and it'd be displayed under that one instead.