Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manual editing of *.designer.cs file

Tags:

c#

designer

I'm aware, that the .designer.cs file contains data generated by the visual form designer in Visual Studio. However, I have some additional methods though, which I want to put into the .designer.cs file as well, because these are responsible for lower-level form handling (for example, pieces of my visual state manager).

The InitializeComponent method inside the .designer.cs file has a comment stating, that it is automatically generated and should not be modified by user. Does this restriction apply only to that method or shouldn't the .designer.cs file be edited by user at all? I've noticed, that among others, it contains the Dispose() method, which the user might want to modify - what suggests the first option. I want to be sure, though.

like image 456
Spook Avatar asked Apr 23 '13 05:04

Spook


People also ask

What is the purpose of the designer CS file in Visual Studio?

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.

What is a designer CCS file while programming?

I'm new in C# and I also want to know more about this automatically created designer.cs file while programming. 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.

What is the CS file in iOS designer?

ViewController. designer. cs is a generated file, created by the iOS Designer to map the visually-constructed interface to code. Since changes to this file will be overwritten, it should not be modified. Property declarations in this file make it possible for code in the ViewController class to access, by Name, controls set up in the iOS Designer.

What is the purpose of the CS file in a form?

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.


1 Answers

You should never modify .designer.cs. Period. Your changes will be overwritten without mercy.

Update: To be a bit more helpful, C# since v3 (VS 2008) has included partial methods, which many designers will now use to let you implement custom behavior.

like image 192
dahlbyk Avatar answered Sep 27 '22 19:09

dahlbyk