Not a bad start at all. A couple things to keep in mind...
While everyone will tell you that global variables are the evil devil spawn that will destroy the known universe... They are sometimes incredibly practical.
Any public property defined in Program.cs will be available to all of the children of Program which would be all the forms and custom controls. I use a
PrivlegesObject class in the Program.cs to hold all the user priveleges (can they edit the configuration, permission to exit the application and so on). This way any form, any class can check the
Program.Priveleges.ExitApp property to see if the user is allowed to do so.
Program.cs contains the one and only Main() method that really is the practical start of your application. The Main() method then launches Form1 or MyStartupWizardForm or whatever form you want to have be the startup form. By default it is Form1, but it doesn't have to be. You can have a working program that launches Form1, but you can work on an upgrade that will launch Form101 when you have the upgrade done. Just change which form is launched in the Program.cs
Program.cs in my case also contains the code to make sure my applications are single instance only. This is also where I have a splash screen launch from. This way the user gets a splash screen right away no matter what. If your Form1 is going to take 10 seconds to read information and set up the user isn't left wondering if the application launched or not, hung or not...
I think of Form1.cs as the logic of Form1 and Form1.Designer.cs as the UI of the Form. If its for looks then it tends to go into the Designer. If it is for behavior then it goes in Form1.cs.
* - Control creation goes in the designer.
* - Event response goes into the Form1.cs -
But this is a really loose way of looking at it. Form1.cs can very easily create a new control and place it on the form programmatically.
Yes you can edit the Dispose() method. But making changes INSIDE the region of automatically created code can be funky. This is why the Dispose() method is outside of the generated code region.
-
protected override void Dispose(bool disposing)
-
{
-
if (disposing && (components != null))
-
{
-
components.Dispose();
-
}
-
base.Dispose(disposing);
-
}
-
-
#region Windows Form Designer generated code
-
// .... generated code for the controls
-
#endregion