Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a class that will be under of a class in solution explorer?

First I created a class file named Bootstrap.cs, then I created another class name Bootstrap.Designer.cs, the awesome part is Bootstrap.Designer.cs become under of first class.

Bootstrap.Designer.cs

So I decide to create another class called Bootstrap.Sample.cs

enter image description here

But the problem here is the third class not become under of first class.

Is there any list of class naming exist like *.Designer.cs that allowed to be under of first class?

like image 500
Leonel Sarmiento Avatar asked Mar 17 '23 20:03

Leonel Sarmiento


1 Answers

You can do this using VSCommands plugin for Visual Studio. Simply highlight the two files, right click in Solution Explorer, and choose group.

If you want to do it manually you can right click on your project file in solution explorer, choose Unload Project. Then you can right click and edit the project, which will allow you to see the underlying XML. You're looking for

<Compile Include="yourfilename.cs" />

which you will need to change to

<Compile Include="yourfilename.cs">
   <DependentUpon>parentFile.cs</DependentUpon>
</Compile>

This is described in How to group partial class files in Solution Explorer VS2010

like image 114
Greg the Incredulous Avatar answered Apr 08 '23 15:04

Greg the Incredulous