[Solved] Execute code in one form when another form is closed [duplicate]


Yes you can execute whaever you want in FormClosing event, but you need to
declare a static property on Form1 and set value on FormClosing in Form2 , write whatever you want to execute in the set{} method of peroperty.

// in Form 2
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
    Form1.IsForm2Closed = true;
}

// in Form 1
private static _isForm2Closed ;
public static bool IsForm2Closed 
{
    get
    {
        return _isForm2Closed;
    }
    set
    {
        _isForm2Closed = value;

       if(value)
       {
           // do whatever you want to execute here.
       }
    }
}

6

solved Execute code in one form when another form is closed [duplicate]