How to tell VS not to treat a class as a form

M

MuZZy

Hi,

I just wonder if someone came across this small problem: i add a class
file to the C# project and i implement a class derived from Form. Even
though i don't have a resx file assosiated with it VS still treats it as
a form file and on double click it tries to open a form instead of
opening code. I made change directly to the project file specifying that
this file is "code", but VS overrides it.

I havee bunch of those files (where i have form classes or user control
classesbut want VS to treat those as regular classes and not try to show
designer for them ) and it's kind of inconvenient to open those by right
click and choose "View code" rather that just double clicking.

Any ideas?

Thank you,
MuZZy
 
R

Robbe Morris [C# MVP]

Forms are classes. You are also inheriting the class Form.
How would visual studio which developers want
the form to render in the designer and which developers don't.

Just right click the class and click View Code. It
can't be that "inconvenient".
 
G

Guest

Also, you can right-click on one of those files and click Open With ...
Select CSharp Editor and then click the Set as Default & OK buttons.
From then on you'll be able to double-click those files to open them in code
view.

Tony
 
M

MuZZy

Robbe said:
Forms are classes. You are also inheriting the class Form.
How would visual studio which developers want
the form to render in the designer and which developers don't.

Well, for example if there is no associated *.resx file it's logically
to treat that class as just class - anyway VS will fail to load designer
if there is no *.resx for *.cs
 
M

MuZZy

tlkerns said:
Also, you can right-click on one of those files and click Open With ...
Select CSharp Editor and then click the Set as Default & OK buttons.
From then on you'll be able to double-click those files to open them in code
view.

That's actually a very good idea! I open code times more often than
designer so it shoudl work well for me!

Thanks a lot!
 
L

Linda Liu [MSFT]

Hi MuZZy,

Thank you for posting.

Once you inherit a class from Form, the class is of type Form which has a
UI. When you double click a class with a UI in Solution Explorer, it is the
default behavior for VS to display it in the designer. As far as I know,
there is no way to change this default behavior.

If you want to display a class with a UI in a code view, you could select
this class in Solution Explorer and click the View Code button on the head
of the Solution Explorer, or press F7.

Hope this helps.
If you have anything unclear, please don't hesitate to let me know



Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 
G

Guest

View-->Class View. In the Class View tab open any form, you won't get the
GUI...

my 2 cents...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top