Link to home
Create AccountLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

Why do I sometimes get mydialog.designer.cs?

Sometimes I create a dialog and get an extra file, where the generated code gets placed.  I don't like it and would like to change it back.

Is there a safe way to switch back to the normal method?  Also, how do I prevent it from happening in the first place?

thanks,
newbieweb
ASKER CERTIFIED SOLUTION
Avatar of ZachSmith
ZachSmith
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
In the Solution Explorer, there is a button at the top that looks like several (3) documents stacked on top of each other. If you click that it should hide the designer files.
Actually, that button doesn't hide those specific types of files, it hides other files within the project.
And to answer your other question, I don't believe there is a good way to disable the use of partial classes. Here is an article about it:

http://visualbasic.about.com/od/usingvbnet/a/partialclasses.htm
Avatar of curiouswebster

ASKER

No, I am not trying to hide it.  When I create a dialog class I sometimes get two files, and I sometimes get three files.

I normally get myclass.cs and myclass.resx.

But sometimes I also get myclass.Designer.cs

I don't want the designer class and need to know how to stop it from being created.  I want all the generated code in one place, in the myclass.cs file.
Unfortunately you can't stop it from being created. The only option you have is to let Visual Studio create the file, then open the file and copy the code over to the myclass.cs file.
But it usually creates it the way I want: just two files.  Something must cause it to be sometimes different with three files.

What are the other types you are creating? Regular classes won't be created that way, and some custom controls won't be created like that either.

Does it happen when you add a new Form to the project?
When I added a Windows Form.  But not all the time.

Maybe I should simply copy an existing Windows Form class (with the two files), then rename it for the new.

It's strange how VS seems to create two, or three, files inconsistently.
Yeah that is very strange. Which version of Visual Studio are you running?
VS 2005.

I noticed it is a partial class.  I think that's the problem.

Why would it create a partial class sometimes, but not all the time??
Yes, they are partial classes. I don't know why it would do it sometimes but not other times. In my experience, every form is created as a partial class in VS 2005. User controls are also created that way. Is the project you are working on one that used to be ini VS 2003?

What is the reason for you not wanting the Designer.cs file?