A Form won't close

Y

Yuriy Zubarev

Hello everyone,

I have main application form (child of System.Windows.Forms.Form) that
hosts quite a number of different visual components. Some time after
working with those components, the form refuses to be closed - I click
menu item that invokes Form.Close() method, I click 'close' icon on
the caption of the window (form) - nothing happens. No event comes to
Form_Closing(Object, CancelEventArgs) method either.

I'm at a loss how to even start debugging this situation and I would
appreciate any suggestions.

Thank you for your time,
Yuriy ZUbarev
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Yuriy,

Known issue when you juggle with dynamically created controls. You should
call OnControlRemoved method on the ultimate control's container just after
you've removed the control from the container's Controls collection. This
method is protected as far as I remember, so if you use Panels, you should
probably create a container control inherited from the Panel.
 
T

Tony

If you set these up using the form properties events options check that
these havent been reset.
I have had it a couple of times that the event handlers get reset so that no
function is then called as a result of control being actioned.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top