winform 订阅事件,关闭后要移除,避免引用

                ITempFrmDeleagte sendtempfrm = tableForm as ITempFrmDeleagte;
                if (sendtempfrm != null)
                {

                    sendtempfrm.OpenModifyFrm += mainDialog.sendtempfrm_OpenModifyFrm;
                    sendtempfrm.OpenPrintFrm += mainDialog.sendtempfrm_OpenPrintFrm;

                    tableForm.Disposed += delegate
                    {
                        sendtempfrm.OpenModifyFrm -= mainDialog.sendtempfrm_OpenModifyFrm;
                        sendtempfrm.OpenPrintFrm -= mainDialog.sendtempfrm_OpenPrintFrm;
                    };

                }
原文地址:https://www.cnblogs.com/CoreXin/p/14024013.html