2009-06-28 44 views
0

可能重複:
In Visual Studio (2008) is there a way to have a custom dependent file on another custom file?C# - 在VS2005項目分部類

我如何能在VS2005項目中添加一個部分類,以便它顯示爲隱藏文件的代碼主文件?

例如:我想將我的類屬性保存在一個名爲MyClass.cs的文件中,我想將我的類屬性保存在名爲MyClass.attr.cs的文件中。

當我打開VS2005工程,MyClass.attr.cs -file會顯示爲隱藏文件MyClass.cs代碼,在WinForm應用程序就像Form1.csForm1.Designer.cs

+0

你可以在項目文件中做到這一點 - 請參閱http://stackoverflow.com/questions/727898 – 2009-06-28 16:04:48

回答

0

此行爲在Visual Studio的用戶界面中不可設置,但如果您在記事本中打開* .csproj,則會看到「Form1.designer.cs」被指定爲「Form1.cs」的「子項目」 。

也許有辦法,如何在Visual Studio中使用macors。

2

在你的.csproj文件,你會看到單獨的標籤類,像這樣:

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

更改爲MyClass.attr.cs的條目是這樣的:

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