开发者

solution for performing final work when winform is no longer needed

开发者 https://www.devze.com 2023-01-12 11:34 出处:网络
I need to accomplish the following. 1.) I have a winform (winformA) that is hidden instead of closed 2.) the winform in #1 is a child to the mainform, when i shutdown the mainform, the child form Wi

I need to accomplish the following.

1.) I have a winform (winformA) that is hidden instead of closed

2.) the winform in #1 is a child to the mainform, when i shutdown the mainform, the child form WinformA is disposed. I need to save data from a winform control in the winformA

The content is in a ListView in WinformA. I have tried overriding the dispose and using the destructor ~classname, but the listview items are null at that point. I cannot do it in form closing because i dont want the action to take place until the whole app is being shutdo开发者_Go百科wn. I cannot expose the method to the mainform due to security requirements. I have tried subscribing to Application.ApplicationExit but the event does not fire.

Any idea?


I cannot do it in form closing

You have to do it from your FormClosing event handler. Pay attention to the e.CloseReason value.

Fwiw, the 'security requirements' are a pipe dream with System.Reflection in a programmer's arsenal. You'll have to setup a sandbox to prevent that.


Can you save your items to a variable instead of a UI control?

Then maybe it won't be null when you reference it.

0

精彩评论

暂无评论...
验证码 换一张
取 消