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...

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();
        }
    }
}

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();
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.