0

I am trying to switch between to form in different project currently I am going this:

this.Hide();
 form2 f= new form2();
 f.Show();

the new instance of form2 throws a null exception error. But I think because form2 is not active.

How do I work around this or is there a between way to achieve this.

Thinks...

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by kdcorp87
0

ur code is right if both from in same project.
but if other project add other project in ur reference and the use

using WindowsFormsApplication1;

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            this.Hide();

            WindowsFormsApplication1.Form1 f = new WindowsFormsApplication1.Form1();

            f.Show();
        }
    }
}

Edited by Nick Evan: Fixed formatting

0

ur code is right if both from in same project.
but if other project add other project in ur reference and the use

using WindowsFormsApplication1;

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            this.Hide();

            WindowsFormsApplication1.Form1 f = new WindowsFormsApplication1.Form1();

            f.Show();
        }
    }
}

Edited by Nick Evan: Fixed formatting

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.