I'm sorry if the title is a bit vague. Hehe.
I've had this idea to use different namespaces to control the contents of a second form. Unfortunately, this version uses five namespaces: three for the forms, and two for the contents of the other two forms. What I need to do here is to have the user click one of two buttons in the first form, and it will load the second form, with the using namespace added on the second form, which will load all the classes I need.
Did I make any sense there? I wrote some code, and it works, but it uses three forms. I only need two.
(I cut out the 'using' on the top of the forms, because it is generated by Visual C#, anyway)
The First Form (main)
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 x = new Form2();
x.ShowDialog();
}
private void button2_Click(object sender, EventArgs e)
{
Form3 x = new Form3();
x.ShowDialog();
}
}
}
The Second Form
namespace WindowsFormsApplication1
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
label1.Text = namespace2.Class1.text();
}
}
}
The Third Form
namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
label1.Text = namespace2.Class2.text();
}
}
}
(The second and third forms are almost identical, except for the namespace bit.)
The first namespace
namespace namespace2
{
class Class1
{
public static string text()
{
return "blah 1";
}
}
}
The second namespace
namespace namespace2
{
class Class2
{
public static string text()
{
return "blah 2";
}
}
}
What I'm trying to do here is to replace the "namespace1.Class1.text()" bits on the form to something like "using namespace1;" then "Class1.text();" on the main forms. I think that way, I can get rid of the third form, and use the buttons on the first form to show two possible forms with the second form.
PS: Sorry for the bad names; I was a bit on the rush when the idea came to me.
PPS: Sorry for the lack of the specific terms and whatever. I'm totally new to C#.