Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,
In my application I have a login screen and a main menu screen which is mdiparent. Now when I run application, mainmenu screen get loaded, also at the same time login screen is also displayed and focus is set on login screen. Now when login screen is activated then I am trying to deactivate the main menu and after valid login activate main menu and close the login screen.

The mainmenu form should not be activated till valid login.

How to do this please help??
Posted
Updated 3-Mar-11 2:51am
v2

Display your login screen from within the MainMenu using the myLoginForm.ShowDialog method.
 
Share this answer
 
Comments
Yatin Bhagat 4-Mar-11 1:06am    
i am using showdialog...but it is raising some error
Yatin Bhagat 4-Mar-11 7:19am    
I sort Out The error...But When Using ShowDialog the contents of MainMenu are enabled i am trying to disable the contents and after valid login content should be enabled.
Show your Login Form from the Main method before showing the MainMenu Form
C#
static void Main()
{
  Application.EnableVisualStyles();
  Application.SetCompatibleTextRenderingDefault(false);

  MyLoginForm login = new MyLoginForm();
  if (login.ShowDialog() == DialogResult.Ok)
  {
    Application.Run(new MainmenuForm());
  }
}


Checking for a valid login should be done in MyLoginForm, which should only return OK for a valid login.
 
Share this answer
 
Comments
CS2011 3-Mar-11 13:52pm    
Good Answer
OriginalGriff mentioned it - don't make your login screen a MdiChild - just show it as modal window with "ShowDialog"
 
Share this answer
 
The best advice for you would be: never use MDI!
See also: Question on using MDI windows in WPF[^].
It looks like everyone is unhappy with MDE, for a good reason. You will only irritate all your users with frustrated user experience. Who use it, anyway?

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900