471,306 Members | 1,203 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,306 software developers and data experts.

Why don't partial class files group?

I have a .NET 1.1 form that was migrated into 2.0. Its class file is
in form1.cs. I've created another "code" file named form1.designer.cs
and with this code:

partial class form1

in the same namespace as form1. form1.cs declares its class as

public partial class form1: Form

However, the designer file icon in solution explorer is labeled as c#
in green and not grouped under form1.cs. partial classes I've seen
created in the VS 2005 are always group under the root partial.

Is there something additional I need to do for this to happen?

Thanks,
Brett

Feb 8 '06 #1
4 2104
Brett Romero wrote:
However, the designer file icon in solution explorer is labeled as c#
in green and not grouped under form1.cs. partial classes I've seen
created in the VS 2005 are always group under the root partial.

Is there something additional I need to do for this to happen?


Hi Brett. The grouping of these files is not due to their containing parts
of the same class, but is rather something done by the designer wizard. If
you didn't run the wizard to create them in the new project, they won't be
grouped, although they will compile fine. The only way I know to deal with
this is to first create an identically named form using the wizard, then
close the project and copy the old source files over the generated files. I
hope this helps.
--
Derrick Coetzee, MCAD, MSFT (Speech Server)
This posting is provided "AS IS" with no warranties, and confers no
rights.
Feb 9 '06 #2
So the only way is to create a form? And from there you can't add any
new files to the same group (since the wizard only creates two partial
classes, including the master)?

Thanks,
brettr

Feb 10 '06 #3
Brett Romero wrote:
However, the designer file icon in solution explorer is labeled as c#
in green and not grouped under form1.cs. partial classes I've seen
created in the VS 2005 are always group under the root partial.

Is there something additional I need to do for this to happen?


The grouping of these files is not due to their containing parts
of the same class, but is rather something done by the designer wizard.


So the only way is to create a form? And from there you can't add any
new files to the same group (since the wizard only creates two partial
classes, including the master)?


Well, not from the GUI as far as I know, but if you're willing to go under
the hood there is a way to add files to groups like this. Open up the
project (.csproj) file in a text editor, and find the XML element that looks
like this:

<Compile Include="FileYouWantInGroup.cs" />

Change it to this:

<Compile Include="FileYouWantInGroup.cs">
<DependentUpon>FileWhoseGroupItGoesIn.cs</DependentUpon>
</Compile>

This should do what you want (I'm not sure if it has any other effects).
Normally, however, this is only used for files that are generated from or
otherwise dependent on the "root" file, as the name "DependentUpon" above
suggests. I hope this helps.
--
Derrick Coetzee, MCAD, MSFT (Speech Server)
This posting is provided "AS IS" with no warranties, and confers no
rights.
Feb 10 '06 #4
This is nice Derrick and it worked!

Thanks,
Brett

Feb 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by pawel.pabich | last post: by
1 post views Thread by Bishoy George | last post: by
3 posts views Thread by Brian Richards | last post: by
3 posts views Thread by Lau Lei Cheong | last post: by
3 posts views Thread by Aryan | last post: by
6 posts views Thread by satyanarayan sahoo | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.