Partial classes

D

dbuchanan

Hello,

I made a test project to understand how adding my own partial class to a
form works. It wasn't so easy. I guess it would get easier after I get used
to it.

My question: Why does a partail class for a form not nest itself under the
main form class the way the default partial class (Form1.Designer.cs and
Form1.rsex) does?

I get this...
Form1.Bindings.cs
Form1.cs
Form1.Desinger.cs
Form1.resx

Instead of getting this...
Form1.cs
Form1.Bindings.cs
Form1.Desinger.cs
Form1.resx

Am I doing something wrong?

Douglas
 
J

Jeffrey Tan[MSFT]

Hi Douglas,

This is basicly a VS IDE issue instead of being controlled by .Net Winform
designer, so you'd better post in microsoft.public.vsnet.ide newsgroup in
future.

Anyway, this is actually an undocumented feature of VS IDE. If you use
notepad to open the project file [XXX].csproj, you can find the snippet
like this:

<ItemGroup>
<Compile Include="Form5.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form5.Designer.cs">
<DependentUpon>Form5.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form5.resx">
<SubType>Designer</SubType>
<DependentUpon>Form5.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>

These XML style attributes tell the VS IDE how to treat and open various
source *.cs files in the IDE designer. For example, <SubType>Form</SubType>
tells the IDE to launch form designer to view&edit the *.cs file. While
<DependentUpon>Form5.cs</DependentUpon> tells the IDE to place the current
*.cs item nested under "Form5.cs". So I think <DependentUpon> is what you
wanted.

Thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

dbuchanan

Wow Jeffrey,
Thanks a lot.

I changeed this...
<Compile Include="Form1.Bind.cs">
<SubType>Form</SubType>
</Compile>

to this...
<Compile Include="Form1.Bind.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>

Douglas
 
J

Jeffrey Tan[MSFT]

Glad to see it works for you. If you need further help, please feel free to
post, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top