When my project starts Form1 loads and checks the program license with the server, if everything’s OK it should: show Form2 and close Form1. Afterward when the user would close Form2 with the “x”, the program should end.
What do you think would be the best way of doing it?
So far got only to form2.Show 🙂
...
if (responseFromServer == "OK")
{
Form2 form2 = new Form2();
form2.Show();
}
Thanks!
As you probably know if you use Form1 as your main form then you can’t close it as this will close the application (unless you customize the way the app starts, but that’s more advanced).
One option is to start by creating Form2 as your main form, but keep it hidden, then create and show Form1, and then when the license check is finished, close Form1 and make Form2 visible.
Or you can start by showing Form1 and then when the license check is done, call
Form1.Hide()and then create and show Form2. Then when Form2 is closed by the user, callForm1.Close()in the Form2.Closed event handler: