Click here to Skip to main content
15,867,906 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am working on a custom Component (not a Control!!!!!!) and I want to make events like ControlAdded and ControlRemoved to use them from my custom Form so to receive "notifications" when this Component is added to or removed from my Form's Container collection.

Any idea how can I do this?

What I have tried:

Not something that worked for me... I could not find comprehensive information!!!
Posted
Updated 7-Dec-22 7:56am
v2

There are no events for Components being added or removed. You can NOT add them to your component because there is nothing that is going to tell your component that it's being added to a Container.

Components are not visual objects, but dropping one on a Form is just "sugar" to make it easier to set properties of the Component in the designer. Beyond that, they are not really part of the Form, or control, you drop it on. It's basically just an extension for form and control code to use, just like a normal class.
 
Share this answer
 
Hans Passant has posted a technique for doing this: [^], but, it's a hack.
 
Share this answer
 

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