I'm trying to open a new window form on a button click
In main program's constructor I've got:
form_targeting = new Targeting();
In button1_Click(...) there is:
form_targeting.Show();
and ofc in main program's fields there's
public static Targeting form_targeting;
When opening first time, It works correctly. After closing 2nd window and pressing the button in a 1st window again, I get error:
Cannot access a disposed object. Object name: 'Targeting'.
I've added that into Targeting class but it still doesn't work:
private void Targeting_FormClosing(Object sender, FormClosingEventArgs e)
{
this.Hide();
e.Cancel = true;
}
It works now, I had to write completely the same but using designer :p thanks guys :)