I am somewhat new to Visual Studio (2019) and WinForms. I am currently trying to separate the two classes: one for form design and one for the project logic.
static class Program {
static void Main() {
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
// more logic
}
}
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
// design logic
}
Currently, I'm having difficulty transferring data between Program
and Form1
. I have tried creating public members to exchange this information, but I do not know how to access it (since the form is instantiated with the Application
class.
I have considered leaving Program
as is and moving all of the project code into Form1
. Replacing the Application
class with an instantiation of a form leads to the program not displaying the Form and terminating early.
Form1 foo = new Form1();
Is there a way to separate program and design logic, or should I put all the logic into Form1
?
Thank you for the help.