473,396 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2206
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: pawel.pabich | last post by:
Hajo, I would like to have 2 my own partial classes. For example: Default.aspx.cs Default2.aspx.cs and they both will relate to Default.aspx page.
10
by: ptass | last post by:
Hi In asp.net 2.0 an aspx files .cs file is a partial class and all works fine, however, I thought I’d be able to create another class file, call it a partial class and have that compile and...
7
by: Maxwell2006 | last post by:
Hi, Typically partial classes consist of two .cs files. Can I have them in 3 source file? Thank you,
1
by: Bishoy George | last post by:
In a web application using asp.net 2.0 All my classes are partial classes. - I noticed that partial class cannot be inherited... is that true? - I tried to remove the partial keyword , and I...
3
by: Brian Richards | last post by:
Is there a way to get Studio to group your partial class files in the Solution tree the way it automatically does with forms? (C#) Thanks Brian
3
by: erich | last post by:
In VS2005, creating a new form creates the form class and a partial (frm*.designer.vb) class file and displays the partial class beneath the main form frm*.vb, which is great. However, when...
3
by: Lau Lei Cheong | last post by:
A few quick questions: Is there a limitation on how much partial class files we can have for a single class? And can a ASP.NET page file inherit a class from multiple code-behind files? if so,...
3
by: Aryan | last post by:
Hi, I have problem in creating Partial Class for ASPX pages. As my Codebase file for ASPX page is having more then 2500 lines of code. So its very hard to maintain the code. So I wanted to know,...
6
by: satyanarayan sahoo | last post by:
What’s the role of Partial keyword which is bydefault written for a class in 2.0 ? public partial class Form1 : Form
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.