I want to make a Management Application with a WinForm and i want to Display one Login Form and when the Login Button is clicked, the second Form should appear.
I tried this:
MainProgramm.BringToFrot();
How can i do that?
CodePudding user response:
If you have a FormMain and you want to call a different form from it, you should create an instance of the second form and show it on the screen (as per @Tvde1 comment):
SecondForm secondForm = new SecondForm();
secondForm.Show();
If you want the new form to act as a dialog box, you can use:
secondForm.ShowDialog(this);
CodePudding user response:
What you pretty much to do is add the following code in the Click action of the button that you want:
MainProgram mainProgram=new MainProgram();
mainProgram.ShowDialog();
Or if you prefer
MainProgram mainProgram=new MainProgram();
mainProgram.Show();
CodePudding user response:
There is a typo in your example code. Maybe you should try:
MainProgramm.BringToFront(); // add the missing 'n' letter