473,394 Members | 1,089 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,394 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 1256
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.