944,178 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 6959
  • C# RSS
Nov 2nd, 2009
0

What is designer.cs?

Expand Post »
Hello All,

Can somebody tell me what is designer.cs file in C# and what is its use in programming. I'm new in C# and I also want to know more about this automatically created designer.cs file while programming.

Thanks,

George
Reputation Points: 10
Solved Threads: 0
Light Poster
george_82 is offline Offline
26 posts
since Jun 2009
Nov 2nd, 2009
0
Re: What is designer.cs?
It is a code file automatically generated by your designer to hold the form's layout information that was created using the Visual Studio IDE. Previous versions of Visual Studio stored all of the information contained in the .designer.cs file in the main code file but the split it out due to user feedback.

Basically it means the ".designer.cs" file is for setting up the form where you can drag buttons around, add panels, resize the form, etc. Whenever you make a change visually with the development environment the changes are stored in .designer.cs.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009
Nov 2nd, 2009
0
Re: What is designer.cs?
Also notice the concept of a partial class. The X.cs and X.designer.cs files form the same class but are marked partial so they can be stored separately. You should in general not change the contents of the .designer.cs file, the IDE does that for you.
I give it a look from times to see how things get done, in the case I want to code something manually myself.
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008
Nov 2nd, 2009
0
Re: What is designer.cs?
Thanks for the reply...Is there any use with this designer.cs file Visual Studio.What if i delete this file.
Also what are the files created/required when try to publish a program to executable .
Reputation Points: 10
Solved Threads: 0
Light Poster
george_82 is offline Offline
26 posts
since Jun 2009
Nov 2nd, 2009
0
Re: What is designer.cs?
If I where you I should never delete the designer file. Consider it as a file that must be there as long as you are developing.
Take this test: create a forms app, put a button(whatever) on the form give it a name open the designer file and look the code that is automatically generated for it. Now change some properties of the button (position size etc.) now go to the designer file again and see how the code is changed, without you having to do it.
Most of the time I use VS C# 2008 Express. Under the build menu you will find a Publish option. Use it and see what happens. Happy computing!
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008
Nov 2nd, 2009
1
Re: What is designer.cs?
Click to Expand / Collapse  Quote originally posted by george_82 ...
Thanks for the reply...Is there any use with this designer.cs file Visual Studio.What if i delete this file.
Also what are the files created/required when try to publish a program to executable .

Whatever designing you do ,for that code is generated in designer.cs file.Like you have a picturebox and a panel on your form then the code for these two components will be in generated in designer.cs file automatically as you drag them on your form.The code which is automatically generated for these is:
C# Syntax (Toggle Plain Text)
  1. private System.Windows.Forms.Panel panel1;
  2. private System.Windows.Forms.PictureBox pictureBox1;

And if you delete this file it will create no problem but all the coding (for varoius components of toolbox),you have to include in .cs file.......
And most of the coders do this only..........
They do not include designer.cs file,instead they code for all components of toolbox ..........
Reputation Points: 11
Solved Threads: 12
Junior Poster
vinnijain is offline Offline
145 posts
since Jul 2009
Nov 2nd, 2009
0
Re: What is designer.cs?
thank you for the reply
Reputation Points: 10
Solved Threads: 0
Light Poster
george_82 is offline Offline
26 posts
since Jun 2009
Nov 2nd, 2009
0
Re: What is designer.cs?
Is it "better" to programmatically create form objects at run time or is it better to use the IDE tool box to drag items onto the form?? For example I made a project that had 27 buttons. I decided to create all 27 of them at run time with a for loop instead of manually creating them with the toolbox and used one method to handle all the clicks. Is it better to dynamically create buttons or is it better practice to create form widgets with the tool box?
Reputation Points: 10
Solved Threads: 3
Junior Poster in Training
RunTimeError is offline Offline
54 posts
since Oct 2009
Nov 2nd, 2009
0
Re: What is designer.cs?
Please RunTimeError post your question again in a new thread!!!
Solved threads are not intended to continue with another subject.
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: hi..
Next Thread in C# Forum Timeline: Big Numbers Problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC