c# Show Windows Form

This creates a new instance of type Form:

Form f = new Form();

Which, of course, is a blank form. It would appear that your type is called frmLogin. Normally this sounds like a variable name and not a class name, but the error you’re getting here tells me that it’s a class:

frmLogin.ShowDialog();

Given that, then the quickest way to solve your problem would be to create an instance of your form and show it:

frmLogin login = new frmLogin();
login.ShowDialog();

However, in keeping with naming standards and conventions (to help prevent future confusion and problems), I highly recommend renaming the form itself to something like:

LoginForm

Then you can use something like frmLogin as the variable name, which is a much more common approach:

LoginForm frmLogin = new LoginForm();
frmLogin.ShowDialog();

Leave a Comment