I have followed some advices I got here today and would need a bit more help now:
I have an user control with login logic.
In mainForm I am using this:
private void Form1_Load(object sender, EventArgs e)
{
LoginScreen login = new MainMenu();
login.Parent = this;
login.Dock = DockStyle.Fill;
login.Show();
}
But I guess it is not modal and thus does not stop the original Form application. Sure I would need the main Form to do not continue until the login form is closed (and login sucessfull).
Would using an event correct? Let login object to raise an event that login was successfull and let the MainForm handle it – run the app?
EDIT: This is user control, no ShowDialog method available.
Simply use
ShowDialog()instead ofShow().Besides,
ShowDialog()returns a DialogResult, so you can check if user doesn’t pressOKand close the form in that case:EDIT:
Given that it’s a usercontrol:
ShowDialog()in yourFormLoadcode (the code is similar to the one you posted, but you need to instanciate the login form instead of your usercontrol)