A Form won't close

  • Thread starter Thread starter Yuriy Zubarev
  • Start date Start date
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
 
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.
 
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.
 
Back
Top