A
AMP
Hello,
I am trying to find out the name of the default form and if Im doing
this right
Form2 ( is startup form, not form 1 ):
public class Form2 : System.Windows.Forms.Form
{
private Form1 myForm1 = null;
..........................................
public Form2()
{
InitializeComponent();
}
...............................................................
public void createform()
{
this.myForm1 = new Form1(this);
this.myForm1.Show();
}
private void button1_Click_1(object sender,
System.EventArgs e)
{
this.createform();
}
static void Main()
{
Application.Run(new Form2());
}
Form1:
public class Form1 : System.Windows.Forms.Form
{
private Form2 myForm2 = null;
.............................................................................
public Form1(Form2 frm2)
{ myForm2=frm2;
InitializeComponent();
}
private void button2_Click(object sender,
System.EventArgs e)
{
myForm2.label1.Text = "diff";
}
So you know what I am doing(and it works):
a button on form2 creates form1 and a button on form1 changes some text
on form2
My questions are
The form I send to form1 I send as "this" and it works.Does it have
another instance name?
I have a reference in both forms to the other form, do I need that.It
doesnt seam to work withou it.And most of all....This this the most
professional method of doing this?
Thanks
Mike
I am trying to find out the name of the default form and if Im doing
this right
Form2 ( is startup form, not form 1 ):
public class Form2 : System.Windows.Forms.Form
{
private Form1 myForm1 = null;
..........................................
public Form2()
{
InitializeComponent();
}
...............................................................
public void createform()
{
this.myForm1 = new Form1(this);
this.myForm1.Show();
}
private void button1_Click_1(object sender,
System.EventArgs e)
{
this.createform();
}
static void Main()
{
Application.Run(new Form2());
}
Form1:
public class Form1 : System.Windows.Forms.Form
{
private Form2 myForm2 = null;
.............................................................................
public Form1(Form2 frm2)
{ myForm2=frm2;
InitializeComponent();
}
private void button2_Click(object sender,
System.EventArgs e)
{
myForm2.label1.Text = "diff";
}
So you know what I am doing(and it works):
a button on form2 creates form1 and a button on form1 changes some text
on form2
My questions are
The form I send to form1 I send as "this" and it works.Does it have
another instance name?
I have a reference in both forms to the other form, do I need that.It
doesnt seam to work withou it.And most of all....This this the most
professional method of doing this?
Thanks
Mike