Possible Duplicate:
Does Form.Dispose() call controls inside's Dispose()?
is there a way to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Both the Panel and the Form class have a Controls collection property, which has a Clear() method…
or
But
Clear()doesn’t calldispose()(All it does is remove he control from the collection), so what you need to do isYou need to create a separate list of the references because Dispose also will remove the control from the collection, changing the index and messing up the foreach…