In my application it has a user login and when a user logs in i want it to bring up the second form. Ive tried several differnt methods from which I have found on google search but none have seem to worked. This is an example of the code below:
Then you must not have created another form called Form2. To add another form to your project, go to Project->Add New Item. Select a Form, and design it however you want. Then, if your form is called Form2 that code should work.
Hmm... this is weird. Is the form2 in your application, or is it in a DLL or something? Also, make sure the Name of the form is Form2 exactly. If not, you can either change the name of the form or change the name of the form in the code i gave you.
Thanks for the reply, but now im getting this error and cannont seem to fix it. Any tips or hints?
Error 1 The type or namespace name 'Form2' could not be found (are you missing a using directive or an assembly reference?) C:\Users\Paul\AppData\Local\Temporary Projects\myapp\Form1.cs 28 21 myapp
the "Form2" in JacobJordan's code is a generic name given to a newly added form if you don't give it a meaningful name. if you named your second form something else, then you will put the name of YOUR second form in the place of "Form2" in the code example.
for example, if you named your second form "frmMainAfterLogin", then your code would look like this...
private void button1_Click(object sender, EventArgs e)
if (textBox1.Text == ("admin")) // username
if (textBox2.Text == ("admin")) // password
frmMainAfterLogin f2 = new frmMainAfterLogin();