|Figure 1: New Partial Class File Added
The aspx page WebForm1.aspx has the default code-behind file and the designer file. For example, let's add a partial class to WebForm1 to handle validations for the page. By default, this new class file is not grouped with WebForm1.aspx like the others. Wouldn't it make sense to group this new partial class with the existing group?
The extension VSCommands 2010 has a handy command to join the new class into the existing group. It is as simple as selecting the parent class (in this case, the aspx file) and the new partial class (the aspx.validations.cs file), then clicking on Group Items.
|Figure 2: Using VSCommands to Group Items
From here, a popup window will appear verifying which one should be the parent of the selected files, as shown below for Visual Studio 2010:
|Figure 3: VSCommands Root Item Selector
We'll keep the aspx file as the parent. With this, we now have the following structure in the Solution Explorer:
|Figure 4: New Partial Class Added to Group
The new partial class aspx.validations.cs is now a member of the WebForm1 class group! This also works for Windows Forms projects, and Visual Basic projects as well.
It should be noted that this makes sense for partial classes, but we are not limited to partial classes when grouping them in Solution Explorer! We can join any other class into the group if we wanted. Say, if we have a dedicated helper class for WebForm1 and it is not a partial class, we can still add it to the group. And we can select more than two files at the same time to initiate the item grouping. There will just be more files listed in VSCommands' root item selector in figure 3. It is even possible to attach a class to another sub-item in an existing group, creating deeper levels in the solution tree.
We actually don't need VSCommands to take advantage of this. The grouping is configured in the project file, as shown in the below snippet:
|Figure 6: Project File Configurations