views:

100

answers:

2

Possible Duplicate:
In Visual Studio (2008) is there a way to have a custom dependent file on another custom file?

How can I add a partial class in a VS2005 project so that it shows up as a code behind file for the main file?

For example: I want to keep my class-properties in a file named, MyClass.cs and I want to keep my class-attributes in a file named MyClass.attr.cs.

When I open the VS2005 project, the MyClass.attr.cs-file would show up as a code behind file for MyClass.cs, just like Form1.cs and Form1.Designer.cs in a winform application.

A: 

This behaviour is not posible set in UI of visual Studio, but if you open *.csproj in notepad, you will see, the "Form1.designer.cs" is assigned as "subitem" of "Form1.cs".

Maybe there is way, how to do it with macors in Visual Studio.

TcKs
+2  A: 

In your .csproj file you'll see seperate tags for the classes, like this:

<Compile Include="MyClass.attr.cs" />
<Compile Include="MyClass.cs" />

Change the entry for MyClass.attr.cs to be like this:

<Compile Include="MyClass.attr.cs">
  <DependentUpon>MyClass.cs</DependentUpon>
</Compile>
Steve Dignan