Reputation: 161
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 myform = new Form2();
myform.ShowDialog();
}
}
}
The following code should "launch" form2. They are in the same project, and have the same namespace. I don't understand. I have tried changing the .NET framework from version 4 client to version 4.
Any other ideas?
Upvotes: 0
Views: 13081
Reputation: 13
You can solve this issue in two wais:
Upvotes: 0
Reputation: 31
In my case I created form2
, but renamed it later.
I found that although the name of the form changed, the name of the class remained as I originally created it.
For example:
1. Project->Add Windows Form (Setup.cs
)
2. File->Save Setup.cs as... (frmSetup.cs
)
3. Add code: frmSetup SetupForm = new frmSetup();
However, the actual name of the Setup class did not change with the file name, so changing my code to:
Setup SetupForm = new Setup();
So I was referencing the class name and not the file name solved the problem for me.
Upvotes: 3
Reputation: 7452
right click on Form2, chose "resolve" and pick one of the resolutions, alternatively move it to the WindowsFormsApplication3
namespace.
Upvotes: 3