Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to control a second window display from a main. In a checkbox from window one I call either a show() or hide method(). I trap the closing method of the second window to prevent it from closing so as to keep the window 2 in memory. How can I use the event of the closing method from window 2 to cause the checkbox from window one to be unchecked?

BTW, this is using WPF

Thanks
Posted

1 solution

You can simply define a delegate and add your own event to form2. form1 can then set that event handler to capture the event.

Here some links on delegates and events:

Events and event handling in C#[^]

http://msdn.microsoft.com/en-us/library/aa645739%28VS.71%29.aspx[^]

You could probably also abuse the form2.OnClosed (.net 1.1) or form2.OnFormClosed (.net 2.0 up) event and add a method of form1 to that event to capture it.

Good luck!
 
Share this answer
 
Comments
alleyes 12-Aug-10 12:42pm    
If using OnClosed or OnFormClosed, does that not mean the form is no longer available, thereby not setting the Cancel property?
alleyes 12-Aug-10 13:12pm    
Reason for my vote of 2
Two examples given that are not in the context of the problem
E.F. Nijboer 12-Aug-10 18:32pm    
In that case you could use the OnClosing/OnFormClosing events. By the way, The examples given are simply in case you would create your own event in form2 and use that instead of hooking into the Closing/Closed events.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900