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;
                    };

                }

 

posted @ 2020-11-23 13:44  欣欣点灯  阅读(149)  评论(0编辑  收藏  举报