471,310 Members | 1,026 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

"partial" - making a part of a class dependant on the main in thesolution explorer

I was trying to break some of my sections of code up into seperate files
using the new "partial" type definition and coudln't figure out how to
make the new files appear under the main file...

The only thing I could figure out to do was to open the .csproj file in
my text editor and change it so that it read "depends on"
Is there a way in the VS gui to do this?
Nov 29 '05 #1
6 1114
Benny,

No, there is not. If you want a file to be dependent on another, you
have to have a specific designer for it, I believe. Otherwise, it just
shows up as another file.

What I usually do is have the file named in two parts. The first part
is the class name, the second part being what the partial implementation is
doing, and then the extension. Something like this:

MyClass.CodeThatDoesOneThing.cs
MyClass.CodeThatDoesOtherThings.cs

This way, they are grouped together when looking at them in solution
explorer.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Benny Raymond" <be***@pocketrocks.com> wrote in message
news:eH*************@TK2MSFTNGP09.phx.gbl...
I was trying to break some of my sections of code up into seperate files
using the new "partial" type definition and coudln't figure out how to make
the new files appear under the main file...

The only thing I could figure out to do was to open the .csproj file in my
text editor and change it so that it read "depends on"
Is there a way in the VS gui to do this?

Nov 29 '05 #2
Nicholas, I noticed that you can open the .csproj in a text editor and
add a line to where you want files to appear under other files. Here's
an example:

<Compile Include="frmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmMain.Designer.cs">
<DependentUpon>frmMain.cs</DependentUpon>
</Compile>
<Compile Include="frmMain.Events.frmMain.cs">
<DependentUpon>frmMain.cs</DependentUpon>
<SubType>Form</SubType>
</Compile>
the "SubType>Form" gets added automatically - kinda dumb if you ask me.
Anyway, hopefully they will make this part of the gui in the future - I
don't like opening the .csproj file in a text editor.

~Benny
Nov 29 '05 #3
I don't believe this was the intended use. In fact, I would say this is
probably bad practice.

--

Derek Davis
dd******@gmail.com

"Benny Raymond" <be***@pocketrocks.com> wrote in message
news:eb**************@TK2MSFTNGP14.phx.gbl...
Nicholas, I noticed that you can open the .csproj in a text editor and add
a line to where you want files to appear under other files. Here's an
example:

<Compile Include="frmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmMain.Designer.cs">
<DependentUpon>frmMain.cs</DependentUpon>
</Compile>
<Compile Include="frmMain.Events.frmMain.cs">
<DependentUpon>frmMain.cs</DependentUpon>
<SubType>Form</SubType>
</Compile>
the "SubType>Form" gets added automatically - kinda dumb if you ask me.
Anyway, hopefully they will make this part of the gui in the future - I
don't like opening the .csproj file in a text editor.

~Benny

Nov 30 '05 #4
Hi,

I agree with you, using Nicholas's suggestion is the best approach, IMO

It's not a good idea hand touching the files generated for internal uses of
VS
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"carion1" <dd******@gmail.com> wrote in message
news:eZ****************@TK2MSFTNGP12.phx.gbl...
I don't believe this was the intended use. In fact, I would say this is
probably bad practice.

--

Derek Davis
dd******@gmail.com

"Benny Raymond" <be***@pocketrocks.com> wrote in message
news:eb**************@TK2MSFTNGP14.phx.gbl...
Nicholas, I noticed that you can open the .csproj in a text editor and
add a line to where you want files to appear under other files. Here's
an example:

<Compile Include="frmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmMain.Designer.cs">
<DependentUpon>frmMain.cs</DependentUpon>
</Compile>
<Compile Include="frmMain.Events.frmMain.cs">
<DependentUpon>frmMain.cs</DependentUpon>
<SubType>Form</SubType>
</Compile>
the "SubType>Form" gets added automatically - kinda dumb if you ask me.
Anyway, hopefully they will make this part of the gui in the future - I
don't like opening the .csproj file in a text editor.

~Benny


Nov 30 '05 #5
But why then would it be there, why would VS create it's own partial
files that show up in a tree under the file they are bound to but not
allow you to do this yourself?

Adding the XML line to the .csproj moves the file where it should be and
doesn't appear to affect the application at all. This line in XML looks
like it's strictly for display purposes.

Regardless, the fact that when you create a form and it puts the
designer code in a file under the form's main .cs file and the fact that
there is seemingly no way (without a little bit of hackary) to do this
yourself seems like a bug in the VS 2005 gui.

~Benny
Nov 30 '05 #6
Also, microsoft actually tells you to do exactly what I did... look at
this post:

http://lab.msdn.microsoft.com/produc...f-09923e76fee8
Nov 30 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Gomaw Beoyr | last post: by
8 posts views Thread by =?Utf-8?B?UiBSZXllcw==?= | last post: by
reply views Thread by rosydwin | 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.