Calling a Mdi child Form from a modal one

  • Thread starter Thread starter Katty
  • Start date Start date
K

Katty

The application loads the main form (mdi parent) and
then it shows a modal form for validation porpuses.
After the user writes the password the validation form
closes, and then I need to call a Mdi child form. How
can I do this?
 
This probably should have been posted in the "windowsforms" group, but here's
one way to do this (in c#):

In your modal form set this.DialogResult = DialogResult.OK if the
authentication was successful, else set this.DialogResult =
DialogResult.Cancel (or No, or Abort, see the DialogResult enumeration).

In your MDI form:

MyModalForm myModalForm = new MyModalForm();
myModalForm.ShowDialog();
if (myModalForm.DialogResult == DialogResult.OK) // successful authentication
{
MyChildForm myChildForm = new MyChildForm();
myChildForm.Parent = this;
myChildForm.Show();
}
else // failed authentication
{
MessageBox.Show("Failed authentication. Bye.");
Application.Exit();
}

Hope this helps,
Kenneth Russo
USCA5
 
Back
Top