I've never liked the Visual Studio [Design]
tab when creating my forms, which is why I always create my forms programmatically from a scratch and I only use one .cs
file, such as Form1.cs
. Just today I noticed that creating a new Form with the [Design]
tab also creates a file called *.Designer.cs
, which handles all the design related stuff.
Since I'm doing my forms manually, should I still use *.Designer.cs
file? If so, when, how and why should I use it? What is the *.Designer.cs
file meant to do, is it only to separate VS auto-generated code from the user code, or does it have a deeper meaning?
Here's an example on how I create my Forms:
class MyForm : Form
{
TextBox file;
Button open, close;
MyForm()
{
InitControls();
}
void InitControls()
{
file = new TextBox();
file.Location = Point(...);
open = new TextBox();
open.Text = "Open File";
...
}
}
Should I separate my InitControls
method and variable declarations to .Designer.cs
file?