473,386 Members | 1,883 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,386 software developers and data experts.

Stop Designer from popping up on a .cs file?

I had a lot of code in Form1.cs, so I moved some of it into another file,
Form1Op.cs, which is still a partial class of Form1 : Form.

Whenever I open Form1Op.cs, it wants to open in Form Designer rather than in
View Code. How can I change that? (Or can I?)

It compiles fine.

Oct 29 '08 #1
17 3072
"Michael A. Covington" <mc@uga.eduwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>I had a lot of code in Form1.cs, so I moved some of it into another file,
Form1Op.cs, which is still a partial class of Form1 : Form.

Whenever I open Form1Op.cs, it wants to open in Form Designer rather than
in View Code. How can I change that? (Or can I?)
I doubt it. Think about it. The code in Form1.cs is more than likely just
functional code, not the stuff that defines the UI (that's in
Form1.Designer.cs), but what happens when you double-click on Form1? The
designer opens. It would be kind of nice if the IDE would open the designer
only when you double-click the .Designer file and open everything else in
code mode, but I'm sure as many people would complain about that as would
enjoy it.
Oct 29 '08 #2
If you are talking about when you double click on the file name in Solution
Explorer, just right click and view code.

"Jeff Johnson" <i.***@enough.spamwrote in message
news:%2*****************@TK2MSFTNGP06.phx.gbl...
"Michael A. Covington" <mc@uga.eduwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>I had a lot of code in Form1.cs, so I moved some of it into another file,
Form1Op.cs, which is still a partial class of Form1 : Form.

Whenever I open Form1Op.cs, it wants to open in Form Designer rather than
in View Code. How can I change that? (Or can I?)

I doubt it. Think about it. The code in Form1.cs is more than likely just
functional code, not the stuff that defines the UI (that's in
Form1.Designer.cs), but what happens when you double-click on Form1? The
designer opens. It would be kind of nice if the IDE would open the
designer only when you double-click the .Designer file and open everything
else in code mode, but I'm sure as many people would complain about that
as would enjoy it.

Oct 29 '08 #3
"Mel Weaver" <Me***********@Insdirect.comwrote in message
news:OF****************@TK2MSFTNGP06.phx.gbl...
If you are talking about when you double click on the file name in
Solution Explorer, just right click and view code.
Yes, of course, but I assumed the poster was talking about the "default"
action, i.e., what happens when you double-click, not that he HAD to open it
in Design view and then switch to Code view from there.
Oct 29 '08 #4
MC
"Jeff Johnson" <i.***@enough.spamwrote in message news:%2****************@TK2MSFTNGP02.phx.gbl...
"Mel Weaver" <Me***********@Insdirect.comwrote in message
news:OF****************@TK2MSFTNGP06.phx.gbl...

>If you are talking about when you double click on the file name in
Solution Explorer, just right click and view code.
Yes, of course, but I assumed the poster was talking about the "default"
action, i.e., what happens when you double-click, not that he HAD to open it
in Design view and then switch to Code view from there.
Right; I was hoping I could find something to put in the file to keep Designer from thinking it's a form. Also, I'm afraid of corrupting Form1.Designer.cs by running Designer on the wrong code file -- although the way they're named, that shouldn't happen.
Oct 30 '08 #5
Michael A. Covington wrote:
I had a lot of code in Form1.cs, so I moved some of it into another
file, Form1Op.cs, which is still a partial class of Form1 : Form.

Whenever I open Form1Op.cs, it wants to open in Form Designer rather
than in View Code. How can I change that? (Or can I?)

It compiles fine.
Every IComponent implementing class has this behavior: it will force
vs.net to open the designer for the type of class.

You can disable this by annotating the class with an attribute. After
that, you can double click it and code is shown. Be sure to type the
full namespace in the attribute even though it's in the using blocks.
attribute to use on the class:
[System.ComponentModel.DesignerCategory("Code")]

Haven't tested it on a form, but IMHO it should work.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Oct 30 '08 #6
Hello mc,
"Jeff Johnson" <i.***@enough.spamwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>"Mel Weaver" <Me***********@Insdirect.comwrote in message
news:OF****************@TK2MSFTNGP06.phx.gbl...
>>If you are talking about when you double click on the file name in
Solution Explorer, just right click and view code.
Yes, of course, but I assumed the poster was talking about the
"default" action, i.e., what happens when you double-click, not that
he HAD to open it in Design view and then switch to Code view from
there.
Right; I was hoping I could find something to put in the file to keep
Designer from thinking it's a form. Also, I'm afraid of corrupting
Form1.Designer.cs by running Designer on the wrong code file --
although the way they're named, that shouldn't happen.
even if you open your Form1Op.cs, the designer will still write all its stuff
to the .designer.cs file, so no worries there...
--
Jesse Houwing
jesse.houwing at sogeti.nl
Oct 30 '08 #7
MC
"Frans Bouma [C# MVP]" <pe******************@xs4all.nlwrote in message news:Oa**************@TK2MSFTNGP02.phx.gbl...

Every IComponent implementing class has this behavior: it will force
vs.net to open the designer for the type of class.

You can disable this by annotating the class with an attribute. After
that, you can double click it and code is shown. Be sure to type the
full namespace in the attribute even though it's in the using blocks.
attribute to use on the class:
[System.ComponentModel.DesignerCategory("Code")]

Haven't tested it on a form, but IMHO it should work.
Thanks -- if it works, that's exactly what I was looking for.
Oct 30 '08 #8
"Frans Bouma [C# MVP]" <pe******************@xs4all.nlwrote in message
news:Oa**************@TK2MSFTNGP02.phx.gbl...
You can disable this by annotating the class with an attribute. After
that, you can double click it and code is shown. Be sure to type the full
namespace in the attribute even though it's in the using blocks.
attribute to use on the class:
[System.ComponentModel.DesignerCategory("Code")]
Holy crap, I'm putting this in EVERY service I've ever written right now!!
Oct 30 '08 #9
"Jeff Johnson" <i.***@enough.spamwrote in message
news:O8**************@TK2MSFTNGP02.phx.gbl...
>You can disable this by annotating the class with an attribute. After
that, you can double click it and code is shown. Be sure to type the full
namespace in the attribute even though it's in the using blocks.
attribute to use on the class:
[System.ComponentModel.DesignerCategory("Code")]

Holy crap, I'm putting this in EVERY service I've ever written right now!!
Didn't work for services.
Oct 30 '08 #10
On Oct 29, 3:40 pm, "Michael A. Covington" <m...@uga.eduwrote:
I had a lot of code in Form1.cs, so I moved some of it into another file,
Form1Op.cs, which is still a partial class of Form1 : Form.

Whenever I open Form1Op.cs, it wants to open in Form Designer rather than in
View Code. How can I change that? (Or can I?)

It compiles fine.
Can you right click on the file in question, choose Open With....
Then select the code editor and click the "Set as Default" button.
Thereafter, when you double click the file, it should open in the code
editor.

Chris
Oct 30 '08 #11
"Chris Dunaway" <du******@gmail.comwrote in message
news:53**********************************@e2g2000h sh.googlegroups.com...
>I had a lot of code in Form1.cs, so I moved some of it into another file,
Form1Op.cs, which is still a partial class of Form1 : Form.

Whenever I open Form1Op.cs, it wants to open in Form Designer rather than
in
View Code. How can I change that? (Or can I?)

It compiles fine.

Can you right click on the file in question, choose Open With....
Then select the code editor and click the "Set as Default" button.
Thereafter, when you double click the file, it should open in the code
editor.
I don't know about Michael's issue, but that certainly worked for my
services!! Thanks a bunch!
Oct 30 '08 #12

"MC" <fo**************@www.ai.uga.edu.slash.mcwrote in message
news:Om**************@TK2MSFTNGP06.phx.gbl...
"Frans Bouma [C# MVP]" <pe******************@xs4all.nlwrote in message
news:Oa**************@TK2MSFTNGP02.phx.gbl...
>Every IComponent implementing class has this behavior: it will force
vs.net to open the designer for the type of class.

You can disable this by annotating the class with an attribute. After
that, you can double click it and code is shown. Be sure to type the
full namespace in the attribute even though it's in the using blocks.
attribute to use on the class:
[System.ComponentModel.DesignerCategory("Code")]

Haven't tested it on a form, but IMHO it should work.

Thanks -- if it works, that's exactly what I was looking for.
It stops Designer from working on Form1 at all. I was only wanting to stop
Designer from working on one of the files that is a partial class Form1.
For now, I gave up on splitting Form1 into partial classes and moved the
code back into Form1.cs as a region.

Oct 30 '08 #13

"Chris Dunaway" <du******@gmail.comwrote in message
news:53**********************************@e2g2000h sh.googlegroups.com...
On Oct 29, 3:40 pm, "Michael A. Covington" <m...@uga.eduwrote:
>I had a lot of code in Form1.cs, so I moved some of it into another file,
Form1Op.cs, which is still a partial class of Form1 : Form.

Whenever I open Form1Op.cs, it wants to open in Form Designer rather than
in
View Code. How can I change that? (Or can I?)

It compiles fine.

Can you right click on the file in question, choose Open With....
Then select the code editor and click the "Set as Default" button.
Thereafter, when you double click the file, it should open in the code
editor.
*duh!* yes... that sounds like exactly what is needed. Thanks.

Oct 30 '08 #14

"Michael A. Covington" <mc@uga.eduwrote in message
news:eq**************@TK2MSFTNGP03.phx.gbl...
>
"Chris Dunaway" <du******@gmail.comwrote in message
news:53**********************************@e2g2000h sh.googlegroups.com...
>On Oct 29, 3:40 pm, "Michael A. Covington" <m...@uga.eduwrote:
>>I had a lot of code in Form1.cs, so I moved some of it into another
file,
Form1Op.cs, which is still a partial class of Form1 : Form.

Whenever I open Form1Op.cs, it wants to open in Form Designer rather
than in
View Code. How can I change that? (Or can I?)

It compiles fine.

Can you right click on the file in question, choose Open With....
Then select the code editor and click the "Set as Default" button.
Thereafter, when you double click the file, it should open in the code
editor.

*duh!* yes... that sounds like exactly what is needed. Thanks.
And it isn't. Even THAT won't let me set different default behavior for 2
different files that are partial classes of the same class. Ah well...
Oct 30 '08 #15
"Michael A. Covington" <mc@uga.eduwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>Can you right click on the file in question, choose Open With....
Then select the code editor and click the "Set as Default" button.
Thereafter, when you double click the file, it should open in the code
editor.

*duh!* yes... that sounds like exactly what is needed. Thanks.

And it isn't. Even THAT won't let me set different default behavior for 2
different files that are partial classes of the same class. Ah well...
Yeah, I was pretty sure your situation was too specialized for that to be
the answer.
Oct 30 '08 #16
"Michael A. Covington" <mc@uga.eduwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>
"Michael A. Covington" <mc@uga.eduwrote in message
news:eq**************@TK2MSFTNGP03.phx.gbl...
>>
"Chris Dunaway" <du******@gmail.comwrote in message
news:53**********************************@e2g2000 hsh.googlegroups.com...
>>On Oct 29, 3:40 pm, "Michael A. Covington" <m...@uga.eduwrote:
I had a lot of code in Form1.cs, so I moved some of it into another
file,
Form1Op.cs, which is still a partial class of Form1 : Form.

Whenever I open Form1Op.cs, it wants to open in Form Designer rather
than in
View Code. How can I change that? (Or can I?)

It compiles fine.

Can you right click on the file in question, choose Open With....
Then select the code editor and click the "Set as Default" button.
Thereafter, when you double click the file, it should open in the code
editor.

*duh!* yes... that sounds like exactly what is needed. Thanks.

And it isn't. Even THAT won't let me set different default behavior for 2
different files that are partial classes of the same class. Ah well...
I apologize if this has already been mentioned, I can't see the entire
thread.

Have you tried edition the project.csproj file? You should have something
like this:

<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1Op.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>

try adding "<SubType>Form</SubType>" into the Form1Op.cs Compile so you wind
up like this:

<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1Op.cs">
<SubType>Form</SubType>
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>


Oct 31 '08 #17

"MC" <fo**************@www.ai.uga.edu.slash.mcwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
"John Vottero" <JV******@mvpsi.comwrote in message
news:BB**********************************@microsof t.com...
>Have you tried edition the project.csproj file? You should have
something
like this:

<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1Op.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>

try adding "<SubType>Form</SubType>" into the Form1Op.cs Compile so you
wind
up like this:

<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1Op.cs">
<SubType>Form</SubType>
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>

That sounds promising, but I want to say that Form1Op.cs is *not* a form
(for editing purposes), not that it is one.
In that case, say <SubType>Code</SubType>.

Nov 3 '08 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Carl Rosenberger | last post by:
Hi all, my application does a lot of threading. The output window becomes completely unusable because of all the "thread exited" messages popping up. Is there any way to stop them? ...
0
by: Michael Culley | last post by:
I have a form that I don't want to show in the designer becuase the designer is changing some things I don't want it to change. Is there some sort of attribute I can apply to stop the designer...
2
by: Jim | last post by:
I have some complex (fairly) user controls that I have created. Some of those user controls host other user controls. When I host one of these on a WinForm, I sometimes run into problems where...
1
by: Jim | last post by:
I have some complex (fairly) user controls that I have created. Some of those user controls host other user controls. When I host one of these on a WinForm, I sometimes run into problems where...
0
by: Frnak McKenney | last post by:
Environment: OS Name Microsoft Windows 2000 Professional Version 5.0.2195 Service Pack 4 Build 2195 Microsoft Visual C# .NET 2003 Microsoft Development Environment 2003 Version 7.1.3088...
6
by: Lloyd Sheen | last post by:
It has been a while since I have had to use VS2003 to create asp.net apps. I had forgotten what a terrible HTML editor it is. I have turned off all reformating but cannot get it to stop changing...
3
by: Bill Nguyen | last post by:
Once applied the latest security patches from Microsoft, OL on our VB app client machines keep popping up dialog box asking for permission to send mail using OL. Is there anyway to by pass this...
4
by: Goran Djuranovic | last post by:
Hi all, I am experiencing a strange thing happening with a "designer.vb" page. Controls I manually declare in this page are automatically deleted after I drop another control on a ".aspx" page. -...
2
by: steve | last post by:
I have the very simple derived class below but when I drag the class from the toolbox on to one of my UserControls VS designer extracts the information and puts it into its resource database for the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.