I want to create a form dynamically and than add a new button to form(also dynamically). now I want to write code on button click event , how I can use form properties. (It generates scope issue. ), should I declare my form as public...? [code of program ][1]
private void button3_Click(object sender, EventArgs e)
{
Form myform = new Form();
myform.Show();
myform.Text = "New Dynamic Window";
Button hide = new Button();
hide.Text = "Hide";
hide.Show();
hide.Location = new Point(50, 50);
hide.Click += hide_Click;
myform.Controls.Add(hide);
}
void hide_Click(object sender, EventArgs e)
{
// myform.Hide();
}
when I write myform.Hide(); in
my click event of button it generates error.