473,323 Members | 1,570 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,323 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 1255
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Gomaw Beoyr | last post by:
Two question about the "partial classes" (in the next wersion of ..NET). Question 1 ========== Will partial classes (in the next version of C#) have to be declared "partial" in ALL places. ...
5
by: | last post by:
Hoping someone can help with a simple but puzzling problem. I have some code that I want to build as a class method. The code works fine when I embed it in Page_Load. But when I try to generalize...
2
by: Ranginald | last post by:
Hi, I have two pages. Default.aspx ....Codefile="default.aspx.cs" Inherits="Web" %> and Sculpture.aspx
1
by: Ned | last post by:
I record where equipment is stored by using a text field. There is also a Building/Room table. A certain building has changed prefixes. Is there any way to accomplish a partial "replace" so that...
2
by: snowie | last post by:
I have a simillar problem to what others have had before me. I just can't find the solution in any earlier post here at the scripts (or any other forum). I am calling a web service that returns a...
35
by: Chris | last post by:
Hi, I tried to create a class which must change the propety 'visible' of a <linktag in the masterpage into 'false' when the user is logged. But i get the error: "Object reference not set to an...
8
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
I have a public class called Database.cs. It has public static functions and I call them from ProjectA. The code looks something like: int intConnectionSuccessful = Database.ConnectToDatabase();...
1
by: Aegixx | last post by:
Ok, extremely wierd situation here: (I'll post the code below, after the explanation) I've got a Windows application (.NET 3.5) that has a single Form with a DataGridView embedded. The user...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.