Hi to all I need your help!
I have an assignement i must create an apllication that when opened opens 3 forms and wenn I click on form1 form1 should be the parent form of thw two other forms.
I have created 3 forms form1, fomr2,form3, and showed them on load.
I have two problems:
1. I dont know how to creatae an function for the event of the left click.
So i tried it with a button so i can try to set the parent-child relation.
and then i encotered the second problem:
2:
When i say frm1.Owner=this ; then logicaly it says that frm1 doesnt exist because it is out of scope. So i was forced to do Form2 frm2 = new Form2(); and then frm2.Owner = this; but that isnt the same form that i created on load.
Thank you
Here is the code:
Code:
private void Form1_Load(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
Form3 frm3 = new Form3();
frm2.Show();
frm3.Show();
}
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Owner = this;
frm2.Show();
}
I have managed my app to show a messagebox on a clock on the form. But i cant set the parent-child relationship because: The name frm2 doesnt exist in the curent context
Code:
void Clicked(object sender, EventArgs e)
{
MessageBox.Show("a");
/* frm2.Owner = this;
frm3.Owner = this;*/
}