changing the main form

  • Thread starter Thread starter Jordi Maicas
  • Start date Start date
J

Jordi Maicas

Hello!!

I've just started a new windows form in C#, but when I finished my Form1, I
remembered that I would like to add a new form to login to the App.

So, I need to load first a Form2, and if I login succesfully, show Form1.

¿How could I change the App, to load Form2, and not Form1?

Thanks.
 
In the Program.cs class there would be Main function something like
below

static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}

Change the Application.Run(new Form1()); line to reflect to the login
form.... something like

Application.Run(new LoginForm());


This should work.

Thanks
-Cnu
 
I've got the following error:

Program.cs(18,33): error CS0246: The type or namespace name 'Form2' could
not be found (are you missing a using directive or an assembly reference?)



And in the Solution Explorer, I see Form2.

Any ideas?



"Duggi" <[email protected]> escribió en el mensaje
In the Program.cs class there would be Main function something like
below

static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}

Change the Application.Run(new Form1()); line to reflect to the login
form.... something like

Application.Run(new LoginForm());


This should work.

Thanks
-Cnu
 
I solved.

Thanks.

Peter Duniho said:
Well...is Form2 in the same namespace as Form1? If not, you need to
either fully qualify the type name, or include a using directive (just as
the error tells you).

It's not really possible with the information given here for any of us to
explain the exact error with certainty. You may want to consider looking
more closely at the error and your own code and its structure and see if
you can figure it out yourself. You'll have a lot of problems down the
road if you don't get comfortable dealing with basic compile errors like
this on your own.

Pete
 
Back
Top